avoid pulling when there is no origin
This commit is contained in:
parent
2c6ca30171
commit
75591eb2e8
|
@ -142,7 +142,10 @@ getCurrentBranch = takeWhile (/= '\n')
|
||||||
<$> readProcess "git" ["symbolic-ref", "--short", "HEAD"]
|
<$> readProcess "git" ["symbolic-ref", "--short", "HEAD"]
|
||||||
|
|
||||||
updateFirst :: CmdLine -> IO () -> IO ()
|
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
|
branchref <- getCurrentBranch
|
||||||
let originbranch = "origin" </> branchref
|
let originbranch = "origin" </> branchref
|
||||||
|
|
||||||
|
@ -319,11 +322,15 @@ gitPush hin hout = void $ fromstdin `concurrently` tostdout
|
||||||
h <- fdToHandle hout
|
h <- fdToHandle hout
|
||||||
B.hGetContents h >>= B.putStr
|
B.hGetContents h >>= B.putStr
|
||||||
|
|
||||||
|
hasOrigin :: IO Bool
|
||||||
|
hasOrigin = do
|
||||||
|
rs <- lines <$> readProcess "git" ["remote"]
|
||||||
|
return $ "origin" `elem` rs
|
||||||
|
|
||||||
setRepoUrl :: String -> IO ()
|
setRepoUrl :: String -> IO ()
|
||||||
setRepoUrl "" = return ()
|
setRepoUrl "" = return ()
|
||||||
setRepoUrl url = do
|
setRepoUrl url = do
|
||||||
rs <- lines <$> readProcess "git" ["remote"]
|
subcmd <- ifM hasOrigin (pure "set-url", pure "add")
|
||||||
let subcmd = if "origin" `elem` rs then "set-url" else "add"
|
|
||||||
void $ boolSystem "git" [Param "remote", Param subcmd, Param "origin", Param url]
|
void $ boolSystem "git" [Param "remote", Param subcmd, Param "origin", Param url]
|
||||||
-- same as --set-upstream-to, except origin branch
|
-- same as --set-upstream-to, except origin branch
|
||||||
-- may not have been pulled yet
|
-- may not have been pulled yet
|
||||||
|
|
Loading…
Reference in New Issue