1 ! Copyright (C) 2009 Joe Groff.
2 ! See https://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 ;
9 : git-object-id ( filename rev -- id/f )
10 [ [ parent-directory ] [ file-name ] bi ] dip swap '[
11 { "git" "ls-tree" } _ suffix _ suffix ascii [
13 [ " " split1 nip " " split1 nip "\t" split1 drop ]
18 : with-git-object-stream ( id quot -- )
19 [ { "git" "cat-file" "-p" } swap suffix utf8 ] dip with-process-reader ; inline
22 ERROR: git-revision-not-found path ;
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* ;
29 SYNTAX: USE-REV: scan-token scan-token use-vocab-rev ;