From 530d9ff6bea5570d051d07546a128d456b3c5c3b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Feb 2018 11:41:57 -0400 Subject: Avoid crashing if initial fetch from origin fails when spinning a host. --- debian/changelog | 1 + .../comment_1_be4533d304096f431ac8d35bbf990dab._comment | 13 +++++++++++++ src/Propellor/Git/VerifiedBranch.hs | 11 ++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 doc/forum/--spin_tries_to_pull_from_central_repository__63__/comment_1_be4533d304096f431ac8d35bbf990dab._comment diff --git a/debian/changelog b/debian/changelog index 55ca5a93..bc7a4a69 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ 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. + * Avoid crashing if initial fetch from origin fails when spinning a host. -- Joey Hess Mon, 19 Feb 2018 12:44:24 -0400 diff --git a/doc/forum/--spin_tries_to_pull_from_central_repository__63__/comment_1_be4533d304096f431ac8d35bbf990dab._comment b/doc/forum/--spin_tries_to_pull_from_central_repository__63__/comment_1_be4533d304096f431ac8d35bbf990dab._comment new file mode 100644 index 00000000..e79fabfb --- /dev/null +++ b/doc/forum/--spin_tries_to_pull_from_central_repository__63__/comment_1_be4533d304096f431ac8d35bbf990dab._comment @@ -0,0 +1,13 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2018-02-22T15:34:07Z" + content=""" +--spin has always pushed/pulled from origin, if there is +a central git repository. + +It's an optional thing though, since the update is pushed directly to the +host it spins too. + +I've improved the code to avoid this particular crash.. +"""]] diff --git a/src/Propellor/Git/VerifiedBranch.hs b/src/Propellor/Git/VerifiedBranch.hs index 51fcb573..df607bd2 100644 --- a/src/Propellor/Git/VerifiedBranch.hs +++ b/src/Propellor/Git/VerifiedBranch.hs @@ -30,12 +30,17 @@ verifyOriginBranch originbranch = do -- Returns True if HEAD is changed by fetching and merging from origin. fetchOrigin :: IO Bool fetchOrigin = do + fetched <- actionMessage "Pull from central git repository" $ + boolSystem "git" [Param "fetch"] + if fetched + then mergeOrigin + else return False + +mergeOrigin :: IO Bool +mergeOrigin = do branchref <- getCurrentBranch let originbranch = "origin" branchref - void $ actionMessage "Pull from central git repository" $ - boolSystem "git" [Param "fetch"] - oldsha <- getCurrentGitSha1 branchref keyring <- privDataKeyring -- cgit v1.2.3