From 98dad1f10e92424871f7356469f42481b40256a6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 19 Feb 2018 11:55:44 -0400 Subject: comment typo --- src/Propellor/DotDir.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Propellor/DotDir.hs') diff --git a/src/Propellor/DotDir.hs b/src/Propellor/DotDir.hs index f62b38f8..17eb095a 100644 --- a/src/Propellor/DotDir.hs +++ b/src/Propellor/DotDir.hs @@ -389,7 +389,7 @@ checkRepoUpToDate = whenM (gitbundleavail <&&> dotpropellorpopulated) $ 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. +-- must have set that up and is not using the distrepo, so do nothing. updateUpstreamMaster :: String -> IO () updateUpstreamMaster newref = unlessM (hasRemote "upstream") $ do changeWorkingDirectory =<< dotPropellor -- cgit v1.3-2-g0d8e From 6f18e665ca8d960a77e437d8edec8f3d14169585 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 19 Feb 2018 12:46:16 -0400 Subject: Warn again about new upstream version when ~/.propellor was cloned from the Debian git bundle using an older version of propellor that set up an upstream remote. This commit was sponsored by Jake Vosloo on Patreon. --- debian/changelog | 8 ++++ ...nt_12_aea497eeecb077659db3f1dfb1e5f289._comment | 20 ++++++++++ src/Propellor/DotDir.hs | 45 +++++++++++++++++----- src/Propellor/Git.hs | 4 ++ 4 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 doc/forum/__42____42___warning:___42____42___Your___126____47__.propellor__47___is_out_of_date../comment_12_aea497eeecb077659db3f1dfb1e5f289._comment (limited to 'src/Propellor/DotDir.hs') diff --git a/debian/changelog b/debian/changelog index 3515497b..55ca5a93 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +propellor (5.3.3) UNRELEASED; urgency=medium + + * Warn again about new upstream version when ~/.propellor was cloned from the + Debian git bundle using an older version of propellor that set up an + upstream remote. + + -- Joey Hess Mon, 19 Feb 2018 12:44:24 -0400 + propellor (5.3.2) unstable; urgency=medium * Added Propellor.Property.Atomic, which can make a non-atomic property diff --git a/doc/forum/__42____42___warning:___42____42___Your___126____47__.propellor__47___is_out_of_date../comment_12_aea497eeecb077659db3f1dfb1e5f289._comment b/doc/forum/__42____42___warning:___42____42___Your___126____47__.propellor__47___is_out_of_date../comment_12_aea497eeecb077659db3f1dfb1e5f289._comment new file mode 100644 index 00000000..90d0ba2c --- /dev/null +++ b/doc/forum/__42____42___warning:___42____42___Your___126____47__.propellor__47___is_out_of_date../comment_12_aea497eeecb077659db3f1dfb1e5f289._comment @@ -0,0 +1,20 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 12""" + date="2018-02-19T15:48:21Z" + content=""" +What propellor --init sets up, when you select the clone option +and the Debian package is installed, is no remote +defined, but a remotes/upsteam/master tracking branch. + +So not normally this: + + upstream /usr/src/propellor/propellor.git (fetch) + +Aha! The very first revision of propellor --init +*did* set up an upstream remote pointing at the distrepo. At some point +that changed to the above described behavior. You're bitten by being an +early adopter. + +I've adjusted the logic to handle that case. +"""]] diff --git a/src/Propellor/DotDir.hs b/src/Propellor/DotDir.hs index 17eb095a..39c111f6 100644 --- a/src/Propellor/DotDir.hs +++ b/src/Propellor/DotDir.hs @@ -387,16 +387,17 @@ checkRepoUpToDate = whenM (gitbundleavail <&&> dotpropellorpopulated) $ do -- into the user's repository, as if fetching from a upstream remote, -- yielding a new upstream/master branch. -- --- 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 and is not using the distrepo, so do nothing. +-- If there's no upstream/master, or the repo is not using the distrepo, +-- do nothing. updateUpstreamMaster :: String -> IO () -updateUpstreamMaster newref = unlessM (hasRemote "upstream") $ do +updateUpstreamMaster newref = do changeWorkingDirectory =<< dotPropellor - go =<< catchMaybeIO getoldrev + v <- getoldrev + case v of + Nothing -> return () + Just oldref -> go oldref where - go Nothing = return () - go (Just oldref) = do + go oldref = do let tmprepo = ".git/propellordisttmp" let cleantmprepo = void $ catchMaybeIO $ removeDirectoryRecursive tmprepo cleantmprepo @@ -421,13 +422,37 @@ updateUpstreamMaster newref = unlessM (hasRemote "upstream") $ do cleantmprepo warnoutofdate True - getoldrev = takeWhile (/= '\n') - <$> readProcess "git" ["show-ref", upstreambranch, "--hash"] - git = run "git" run cmd ps = unlessM (boolSystem cmd (map Param ps)) $ error $ "Failed to run " ++ cmd ++ " " ++ show ps + -- Get ref that the upstreambranch points to, only when + -- the distrepo is being used. + getoldrev = do + mrev <- catchMaybeIO $ takeWhile (/= '\n') + <$> readProcess "git" ["show-ref", upstreambranch, "--hash"] + print mrev + case mrev of + Just _ -> do + -- Normally there will be no upstream + -- remote when the distrepo is used. + -- Older versions of propellor set up + -- an upstream remote pointing at the + -- distrepo. + ifM (hasRemote "upstream") + ( do + v <- remoteUrl "upstream" + print ("remote url", v) + return $ case v of + Just rurl | rurl == distrepo -> mrev + _ -> Nothing + , return mrev + ) + Nothing -> return mrev + +-- And, if there's a remote named "upstream" +-- that does not point at the distrepo, the user must have set that up +-- and is not using the distrepo, so do nothing. warnoutofdate :: Bool -> IO () warnoutofdate havebranch = do warningMessage ("** Your ~/.propellor/ is out of date..") diff --git a/src/Propellor/Git.hs b/src/Propellor/Git.hs index 10b88ddd..c446f67a 100644 --- a/src/Propellor/Git.hs +++ b/src/Propellor/Git.hs @@ -30,6 +30,10 @@ hasRemote remotename = catchDefaultIO False $ do rs <- lines <$> readProcess "git" ["remote"] return $ remotename `elem` rs +remoteUrl :: String -> IO (Maybe String) +remoteUrl remotename = catchDefaultIO Nothing $ headMaybe . lines + <$> readProcess "git" ["config", "remote." ++ remotename ++ ".url"] + hasGitRepo :: IO Bool hasGitRepo = doesFileExist ".git/HEAD" -- cgit v1.3-2-g0d8e From 335b5fba4f86929836c9eb59baa8fbd0d311dcf8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 19 Feb 2018 12:49:03 -0400 Subject: output warning message atomically Before part went to stderr and part to stdout, and the two parts could be reordered in some cases, particularly when concurrent output caused them to be buffered. This commit was sponsored by Trenton Cronholm on Patreon. --- src/Propellor/DotDir.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/Propellor/DotDir.hs') diff --git a/src/Propellor/DotDir.hs b/src/Propellor/DotDir.hs index 39c111f6..be5d614d 100644 --- a/src/Propellor/DotDir.hs +++ b/src/Propellor/DotDir.hs @@ -454,11 +454,12 @@ updateUpstreamMaster newref = do -- that does not point at the distrepo, the user must have set that up -- and is not using the distrepo, so do nothing. warnoutofdate :: Bool -> IO () -warnoutofdate havebranch = do - warningMessage ("** Your ~/.propellor/ is out of date..") - let also s = infoMessage [" " ++ s] - also ("A newer upstream version is available in " ++ distrepo) - if havebranch - then also ("To merge it, run: git merge " ++ upstreambranch) - else also ("To merge it, find the most recent commit in your repository's history that corresponds to an upstream release of propellor, and set refs/remotes/" ++ upstreambranch ++ " to it. Then run propellor again.") - also "" +warnoutofdate havebranch = warningMessage $ unlines + [ "** Your ~/.propellor/ is out of date.." + , indent "A newer upstream version is available in " ++ distrepo + , indent $ if havebranch + then "To merge it, run: git merge " ++ upstreambranch + else "To merge it, find the most recent commit in your repository's history that corresponds to an upstream release of propellor, and set refs/remotes/" ++ upstreambranch ++ " to it. Then run propellor again." + ] + where + indent s = " " ++ s -- cgit v1.3-2-g0d8e From 9d167ac2e64fc3f791ac2695e7a65a70446c80ea Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 19 Feb 2018 12:55:20 -0400 Subject: cleanup debug --- src/Propellor/DotDir.hs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/Propellor/DotDir.hs') diff --git a/src/Propellor/DotDir.hs b/src/Propellor/DotDir.hs index be5d614d..125cec3f 100644 --- a/src/Propellor/DotDir.hs +++ b/src/Propellor/DotDir.hs @@ -392,12 +392,10 @@ checkRepoUpToDate = whenM (gitbundleavail <&&> dotpropellorpopulated) $ do updateUpstreamMaster :: String -> IO () updateUpstreamMaster newref = do changeWorkingDirectory =<< dotPropellor - v <- getoldrev - case v of - Nothing -> return () - Just oldref -> go oldref + go =<< getoldref where - go oldref = do + go Nothing = return () + go (Just oldref) = do let tmprepo = ".git/propellordisttmp" let cleantmprepo = void $ catchMaybeIO $ removeDirectoryRecursive tmprepo cleantmprepo @@ -428,11 +426,10 @@ updateUpstreamMaster newref = do -- Get ref that the upstreambranch points to, only when -- the distrepo is being used. - getoldrev = do - mrev <- catchMaybeIO $ takeWhile (/= '\n') + getoldref = do + mref <- catchMaybeIO $ takeWhile (/= '\n') <$> readProcess "git" ["show-ref", upstreambranch, "--hash"] - print mrev - case mrev of + case mref of Just _ -> do -- Normally there will be no upstream -- remote when the distrepo is used. @@ -442,13 +439,12 @@ updateUpstreamMaster newref = do ifM (hasRemote "upstream") ( do v <- remoteUrl "upstream" - print ("remote url", v) return $ case v of - Just rurl | rurl == distrepo -> mrev + Just rurl | rurl == distrepo -> mref _ -> Nothing - , return mrev + , return mref ) - Nothing -> return mrev + Nothing -> return mref -- And, if there's a remote named "upstream" -- that does not point at the distrepo, the user must have set that up -- cgit v1.3-2-g0d8e