summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2018-02-22 11:41:57 -0400
committerJoey Hess2018-02-22 11:41:57 -0400
commit530d9ff6bea5570d051d07546a128d456b3c5c3b (patch)
tree0d7d4b390f874780561b037c0a6c34964d8f5298
parent8a3310d5420024454b54ff019afcaaa40a9803f7 (diff)
Avoid crashing if initial fetch from origin fails when spinning a host.
-rw-r--r--debian/changelog1
-rw-r--r--doc/forum/--spin_tries_to_pull_from_central_repository__63__/comment_1_be4533d304096f431ac8d35bbf990dab._comment13
-rw-r--r--src/Propellor/Git/VerifiedBranch.hs11
3 files changed, 22 insertions, 3 deletions
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 <id@joeyh.name> 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