]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/cli/git/git.factor
factor: add newlines to .factor files
[factor.git] / extra / cli / git / git.factor
index bfee6419ff2171e85552887f3f4b92321b4c5a2e..39b42f7fd868601598dce63b936e451bdf9d0e53 100644 (file)
@@ -1,20 +1,17 @@
 ! Copyright (C) 2017 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays concurrency.combinators concurrency.semaphores fry
-io io.directories io.encodings.utf8 io.files.info io.launcher
-io.pathnames kernel math namespaces sequences splitting
-system-info unicode ;
+USING: accessors arrays concurrency.combinators
+concurrency.semaphores io io.directories io.encodings.utf8
+io.files.info io.launcher io.pathnames kernel math namespaces
+sequences splitting system-info unicode ;
 IN: cli.git
 
 SYMBOL: cli-git-num-parallel
 cli-git-num-parallel [ cpus 2 * ] initialize
 
-: git-command>string ( quot -- string )
+: git-command>string ( desc -- string )
     utf8 <process-reader> stream-contents [ blank? ] trim-tail ;
 
-: git-command>lines ( quot -- string )
-    utf8 <process-reader> stream-lines ;
-
 : git-clone-as ( uri path -- process ) [ { "git" "clone" } ] 2dip 2array append run-process ;
 : git-clone ( uri -- process ) [ { "git" "clone" } ] dip suffix run-process ;
 : git-pull* ( -- process ) { "git" "pull" } run-process ;
@@ -25,8 +22,8 @@ cli-git-num-parallel [ cpus 2 * ] initialize
 : git-fetch-tags ( path -- process ) [ git-fetch-tags* ] with-directory ;
 : git-checkout-new-branch* ( branch -- process ) [ { "git" "checkout" "-b" } ] dip suffix run-process ;
 : git-checkout-new-branch ( path branch -- process ) '[ _ git-checkout-new-branch* ] with-directory ;
-: git-checkout-existing-branch* ( branch -- process ) [ { "git" "checkout" } ] dip suffix run-process ;
-: git-checkout-existing-branch ( path branch -- process ) '[ _ git-checkout-existing-branch* ] with-directory ;
+: git-checkout-existing* ( branch/checksum -- process ) [ { "git" "checkout" } ] dip suffix run-process ;
+: git-checkout-existing ( path branch/checksum -- process ) '[ _ git-checkout-existing* ] with-directory ;
 : git-change-remote* ( remote uri -- process ) [ { "git" "remote" "set-url" } ] 2dip 2array append run-process ;
 : git-change-remote ( path remote uri -- process ) '[ _ _ git-change-remote* ] with-directory ;
 : git-remote-add* ( remote uri -- process ) [ { "git" "remote" "add" } ] 2dip 2array append run-process ;
@@ -36,9 +33,9 @@ cli-git-num-parallel [ cpus 2 * ] initialize
 : git-rev-parse* ( branch -- string ) [ { "git" "rev-parse" } ] dip suffix git-command>string ;
 : git-rev-parse ( path branch -- string ) '[ _ git-rev-parse* ] with-directory ;
 : git-diff-name-only* ( from to -- lines )
-    [ { "git" "diff" "--name-only" } ] 2dip 2array append git-command>lines ;
+    [ { "git" "diff" "--name-only" } ] 2dip 2array append process-lines ;
 : git-diff-name-only ( path from to -- lines )
-    [ git-diff-name-only* ] with-directory ;
+    '[ _ _ git-diff-name-only* ] with-directory ;
 
 : git-repository? ( directory -- ? )
     ".git" append-path current-directory get prepend-path
@@ -63,3 +60,8 @@ cli-git-num-parallel [ cpus 2 * ] initialize
             _ [ update-repository ] with-semaphore
         ] parallel-each
     ] with-ensure-directory ;
+
+: directory-entries-without-git ( directory -- entries )
+    recursive-directory-entries
+    [ name>> "/.git/" subseq-index? ] reject ;
+