summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoey Hess2014-11-18 15:43:00 -0400
committerJoey Hess2014-11-18 15:43:30 -0400
commit75591eb2e8ebd08362d91e42038098db852333eb (patch)
tree663b7fd1cbd0543e5262145d67339c4778ab30c1 /src
parent2c6ca3017126a3cd9a7848794e5d9eb1991aa2f1 (diff)
avoid pulling when there is no origin
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/CmdLine.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs
index 2d4ae403..c79b2592 100644
--- a/src/Propellor/CmdLine.hs
+++ b/src/Propellor/CmdLine.hs
@@ -142,7 +142,10 @@ getCurrentBranch = takeWhile (/= '\n')
<$> readProcess "git" ["symbolic-ref", "--short", "HEAD"]
updateFirst :: CmdLine -> IO () -> IO ()
-updateFirst cmdline next = do
+updateFirst cmdline next = ifM hasOrigin (updateFirst' cmdline next, next)
+
+updateFirst' :: CmdLine -> IO () -> IO ()
+updateFirst' cmdline next = do
branchref <- getCurrentBranch
let originbranch = "origin" </> branchref
@@ -319,11 +322,15 @@ gitPush hin hout = void $ fromstdin `concurrently` tostdout
h <- fdToHandle hout
B.hGetContents h >>= B.putStr
+hasOrigin :: IO Bool
+hasOrigin = do
+ rs <- lines <$> readProcess "git" ["remote"]
+ return $ "origin" `elem` rs
+
setRepoUrl :: String -> IO ()
setRepoUrl "" = return ()
setRepoUrl url = do
- rs <- lines <$> readProcess "git" ["remote"]
- let subcmd = if "origin" `elem` rs then "set-url" else "add"
+ subcmd <- ifM hasOrigin (pure "set-url", pure "add")
void $ boolSystem "git" [Param "remote", Param subcmd, Param "origin", Param url]
-- same as --set-upstream-to, except origin branch
-- may not have been pulled yet