utility to load a chosen revision of a vocab from a git repo, e.g. "USE-REV: xml origin/master"

db4
Joe Groff 2009-11-07 23:54:17 -06:00
parent 6047f79996
commit 84d4bd3bbe
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1 @@
Joe Groff

View File

@ -0,0 +1,28 @@
! (c)2009 Joe Groff bsd license
USING: fry io io.directories io.encodings.ascii
io.encodings.utf8 io.launcher io.pathnames kernel lexer
namespaces parser sequences splitting vocabs vocabs.loader ;
IN: vocabs.git
<PRIVATE
: git-object-id ( filename rev -- id/f )
[ [ parent-directory ] [ file-name ] bi ] dip swap '[
{ "git" "ls-tree" } _ suffix _ suffix ascii [
readln
[ " " split1 nip " " split1 nip "\t" split1 drop ]
[ f ] if*
] with-process-reader
] with-directory ;
: with-git-object-stream ( id quot -- )
[ { "git" "cat-file" "-p" } swap suffix utf8 ] dip with-process-reader ; inline
PRIVATE>
ERROR: git-revision-not-found path ;
: use-vocab-rev ( vocab-name rev -- )
[ create-vocab vocab-source-path dup ] dip git-object-id
[ [ input-stream get swap parse-stream call( -- ) ] with-git-object-stream ]
[ git-revision-not-found ] if* ;
SYNTAX: USE-REV: scan scan use-vocab-rev ;