From a4f9c3dcf6822690c9d820f7ab843f397d8804e9 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Fri, 22 Jul 2022 13:39:29 -0400 Subject: [PATCH] Move the `exit` into `main` to remove some action-at-a-distance --- ci-tools/update-nixpkgs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ci-tools/update-nixpkgs b/ci-tools/update-nixpkgs index 76f74a2e..d4afb21f 100755 --- a/ci-tools/update-nixpkgs +++ b/ci-tools/update-nixpkgs @@ -54,8 +54,11 @@ main() { checkout_source_branch "$SSHKEY" "$SERVER_HOST" "$PROJECT_PATH" "$DEFAULT_BRANCH" "$SOURCE_BRANCH" build "result-before" - # If nothing changed, update_nixpkgs will just exit for us. - update_nixpkgs + # If nothing changed, report this and exit without an error. + if ! update_nixpkgs; then + echo "No changes." + exit 0 + fi build "result-after" local DIFF=$(compute_diff "./result-before" "./result-after") @@ -156,11 +159,10 @@ update_nixpkgs() { # file instead of the one that's part of its own checkout. nix-shell ../shell.nix --run 'update-nixpkgs ${PWD}/nixpkgs.json' - # Show us what we did - and signal a kind of error if we did nothing - # (expected in the case where nixpkgs hasn't changed since we last ran). + # Signal a kind of error if we did nothing (expected in the case where + # nixpkgs hasn't changed since we last ran). if git diff --exit-code; then - echo "No changes." - exit 0 + return 1 fi } -- GitLab