diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-12-08 12:00:39 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-12-08 12:00:39 -0400 |
| commit | f11c4835d5952d885c678a49501b1dcc524316ad (patch) | |
| tree | b86635b1bd1bdffe530d4f3b7529cf6c564676b3 /src/Propellor/Spin.hs | |
| parent | 5ecb4944a637c4f28a15746b2ea716850e63a5ab (diff) | |
| parent | 39c0073d2800e23b051188de239efdea9b17793e (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Spin.hs')
| -rw-r--r-- | src/Propellor/Spin.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs index ae7e7af5..bda146cc 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 " + ++ b ++ " branch 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"] |
