mason.git: fix parsing of "git status" command
--porcelain option produces machine readable output. Then if the output is empty, the working tree is clean. The exit code doesn't need to be checked.char-rename
parent
7806bdb953
commit
19616c9714
|
@ -1,9 +1,8 @@
|
||||||
! Copyright (C) 2010 Slava Pestov.
|
! Copyright (C) 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors combinators.short-circuit continuations
|
USING: accessors continuations debugger io io.directories
|
||||||
debugger io io.directories io.directories.hierarchy
|
io.directories.hierarchy io.encodings.utf8 io.files io.launcher
|
||||||
io.encodings.utf8 io.files io.launcher io.sockets
|
io.sockets io.streams.string kernel mason.common mason.email sequences
|
||||||
io.streams.string kernel mason.common mason.email sequences
|
|
||||||
splitting ;
|
splitting ;
|
||||||
IN: mason.git
|
IN: mason.git
|
||||||
|
|
||||||
|
@ -55,19 +54,10 @@ IN: mason.git
|
||||||
] [ rethrow ] if ;
|
] [ rethrow ] if ;
|
||||||
|
|
||||||
: git-status-cmd ( -- cmd )
|
: git-status-cmd ( -- cmd )
|
||||||
{ "git" "status" } ;
|
{ "git" "status" "--porcelain" } ;
|
||||||
|
|
||||||
: git-status-failed ( error -- )
|
|
||||||
! Exit code 1 means there's nothing to commit.
|
|
||||||
dup { [ process-failed? ] [ code>> 1 = ] } 1&&
|
|
||||||
[ drop ] [ rethrow ] if ;
|
|
||||||
|
|
||||||
: git-status ( -- seq )
|
: git-status ( -- seq )
|
||||||
[
|
git-status-cmd utf8 [ lines ] with-process-reader ;
|
||||||
git-status-cmd utf8 [ lines ] with-process-reader*
|
|
||||||
{ 0 1 } member? [ drop ] [ process-failed ] if
|
|
||||||
[ "#\t" head? ] filter
|
|
||||||
] [ git-status-failed { } ] recover ;
|
|
||||||
|
|
||||||
: check-repository ( -- seq )
|
: check-repository ( -- seq )
|
||||||
"factor" [ git-status ] with-directory ;
|
"factor" [ git-status ] with-directory ;
|
||||||
|
|
Loading…
Reference in New Issue