! Copyright (C) 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors continuations debugger io io.directories io.encodings.utf8 io.files io.launcher io.sockets io.streams.string kernel mason.common mason.email sequences splitting ; IN: mason.git : git-id ( -- id ) { "git" "show" } utf8 [ read-lines ] with-process-reader first split-words second ; > "not uptodate. Cannot merge." subseq-of? [ git-repo-corrupted ] [ rethrow ] if ] [ rethrow ] if ; : git-status-cmd ( -- cmd ) { "git" "status" "--porcelain" } ; : git-status ( -- seq ) git-status-cmd utf8 [ read-lines ] with-process-reader ; : check-repository ( -- seq ) "factor" [ git-status ] with-directory ; : repo-dirty-body ( error -- string ) [ "Dirty repository on " write host-name write " will be re-cloned." print "Modified and untracked files:" print nl [ print ] each ] with-string-writer ; : git-repo-dirty ( files -- ) repo-dirty-body "dirty repo" email-fatal "factor" delete-tree git-clone ; PRIVATE> : git-clone-or-pull ( -- id ) ! Must be run from builds-dir. "factor" file-exists? [ check-repository [ "factor" [ [ git-pull-cmd short-running-process ] [ git-pull-failed ] recover ] with-directory ] [ git-repo-dirty ] if-empty ] [ git-clone ] if "factor" [ git-id ] with-directory ;