]> gitweb.factorcode.org Git - factor.git/blob - extra/vocabs/git/git.factor
change ERROR: words from throw-foo back to foo.
[factor.git] / extra / vocabs / git / git.factor
1 ! (c)2009 Joe Groff bsd license
2 USING: fry io io.directories io.encodings.ascii
3 io.encodings.utf8 io.launcher io.pathnames kernel lexer
4 namespaces parser sequences splitting vocabs vocabs.loader ;
5 IN: vocabs.git
6
7 <PRIVATE
8 : git-object-id ( filename rev -- id/f )
9     [ [ parent-directory ] [ file-name ] bi ] dip swap '[
10         { "git" "ls-tree" } _ suffix _ suffix ascii [
11             readln
12             [ " " split1 nip " " split1 nip "\t" split1 drop ]
13             [ f ] if*
14         ] with-process-reader
15     ] with-directory ;
16
17 : with-git-object-stream ( id quot -- )
18     [ { "git" "cat-file" "-p" } swap suffix utf8 ] dip with-process-reader ; inline
19 PRIVATE>
20
21 ERROR: git-revision-not-found path ;
22
23 : use-vocab-rev ( vocab-name rev -- )
24     [ create-vocab vocab-source-path dup ] dip git-object-id
25     [ [ input-stream get swap parse-stream call( -- ) ] with-git-object-stream ]
26     [ git-revision-not-found ] if* ;
27
28 SYNTAX: USE-REV: scan-token scan-token use-vocab-rev ;