summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/DotDir.hs26
-rw-r--r--src/Propellor/Git.hs7
2 files changed, 20 insertions, 13 deletions
diff --git a/src/Propellor/DotDir.hs b/src/Propellor/DotDir.hs
index e9253b87..f62b38f8 100644
--- a/src/Propellor/DotDir.hs
+++ b/src/Propellor/DotDir.hs
@@ -358,7 +358,7 @@ checkRepoUpToDate = whenM (gitbundleavail <&&> dotpropellorpopulated) $ do
withQuietOutput createProcessSuccess $
proc "git" ["log", headrev]
if (headknown == Nothing)
- then setupUpstreamMaster headrev
+ then updateUpstreamMaster headrev
else do
theirhead <- getCurrentGitSha1 =<< getCurrentBranchRef
when (theirhead /= headrev) $ do
@@ -372,26 +372,30 @@ checkRepoUpToDate = whenM (gitbundleavail <&&> dotpropellorpopulated) $ do
d <- dotPropellor
doesFileExist (d </> "propellor.cabal")
--- Makes upstream/master in dotPropellor be a usefully mergeable branch.
+-- Updates upstream/master in dotPropellor so merging from it will update
+-- to the latest distrepo.
--
--- We cannot just use origin/master, because in the case of a distrepo,
--- it only contains 1 commit. So, trying to merge with it will result
--- in lots of merge conflicts, since git cannot find a common parent
--- commit.
+-- We cannot just fetch the distrepo because the distrepo contains only
+-- 1 commit. So, trying to merge with it will result in lots of merge
+-- conflicts, since git cannot find a common parent commit.
--
--- Instead, the upstream/master branch is created by taking the
--- upstream/master branch (which must be an old version of propellor,
+-- Instead, the new upstream/master branch is updated by taking the
+-- current upstream/master branch (which must be an old version of propellor,
-- as distributed), and diffing from it to the current origin/master,
-- and committing the result. This is done in a temporary clone of the
-- repository, giving it a new master branch. That new branch is fetched
-- into the user's repository, as if fetching from a upstream remote,
-- yielding a new upstream/master branch.
-setupUpstreamMaster :: String -> IO ()
-setupUpstreamMaster newref = do
+--
+-- If there's no upstream/master, the user is not using the distrepo,
+-- so do nothing. And, if there's a remote named "upstream", the user
+-- must have set that up is not using the distrepo, so do nothing.
+updateUpstreamMaster :: String -> IO ()
+updateUpstreamMaster newref = unlessM (hasRemote "upstream") $ do
changeWorkingDirectory =<< dotPropellor
go =<< catchMaybeIO getoldrev
where
- go Nothing = warnoutofdate False
+ go Nothing = return ()
go (Just oldref) = do
let tmprepo = ".git/propellordisttmp"
let cleantmprepo = void $ catchMaybeIO $ removeDirectoryRecursive tmprepo
diff --git a/src/Propellor/Git.hs b/src/Propellor/Git.hs
index 1d81c157..10b88ddd 100644
--- a/src/Propellor/Git.hs
+++ b/src/Propellor/Git.hs
@@ -23,9 +23,12 @@ getCurrentGitSha1 branchref = takeWhile (/= '\n')
<$> readProcess "git" ["show-ref", "--hash", branchref]
hasOrigin :: IO Bool
-hasOrigin = catchDefaultIO False $ do
+hasOrigin = hasRemote "origin"
+
+hasRemote :: String -> IO Bool
+hasRemote remotename = catchDefaultIO False $ do
rs <- lines <$> readProcess "git" ["remote"]
- return $ "origin" `elem` rs
+ return $ remotename `elem` rs
hasGitRepo :: IO Bool
hasGitRepo = doesFileExist ".git/HEAD"