summaryrefslogtreecommitdiff
path: root/src/Propellor/Spin.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Spin.hs')
-rw-r--r--src/Propellor/Spin.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs
index ae7e7af5..f01975c9 100644
--- a/src/Propellor/Spin.hs
+++ b/src/Propellor/Spin.hs
@@ -32,6 +32,24 @@ import Utility.SafeCommand
commitSpin :: IO ()
commitSpin = do
+ -- safety check #1: check we're on the configured spin branch
+ spinBranch <- getGitConfigValue "propellor.spin-branch"
+ case spinBranch of
+ Nothing -> return () -- just a noop
+ Just b -> do
+ currentBranch <- getCurrentBranch
+ when (b /= currentBranch) $ error
+ ("spin aborted: check out branch "
+ ++ b ++ " first")
+
+ -- safety check #2: check we can commit with a dirty tree
+ noDirtySpin <- getGitConfigBool "propellor.forbid-dirty-spin"
+ when noDirtySpin $ do
+ status <- takeWhile (/= '\n')
+ <$> readProcess "git" ["status", "--porcelain"]
+ when (not . null $ status) $
+ error "spin aborted: commit changes first"
+
void $ actionMessage "Git commit" $
gitCommit (Just spinCommitMessage)
[Param "--allow-empty", Param "-a"]