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