]> gitweb.factorcode.org Git - factor.git/commitdiff
utility to load a chosen revision of a vocab from a git repo, e.g. "USE-REV: xml...
authorJoe Groff <arcata@gmail.com>
Sun, 8 Nov 2009 05:54:17 +0000 (23:54 -0600)
committerJoe Groff <arcata@gmail.com>
Sun, 8 Nov 2009 05:54:17 +0000 (23:54 -0600)
extra/vocabs/git/authors.txt [new file with mode: 0644]
extra/vocabs/git/git.factor [new file with mode: 0644]

diff --git a/extra/vocabs/git/authors.txt b/extra/vocabs/git/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/extra/vocabs/git/git.factor b/extra/vocabs/git/git.factor
new file mode 100644 (file)
index 0000000..eb945b5
--- /dev/null
@@ -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 ;