Skip to content

Commit

Permalink
Prevent upgrade command from succeeding when brew update fails (#80)
Browse files Browse the repository at this point in the history
@toddblakey recently saw this error when he was running `ih-setup
upgrade`, but it still continued to say it was up-to-date:
```
INFO: Checking for updates...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error: Fetching /usr/local/Homebrew/Library/Taps/consultingmd/homebrew-ih-public failed!
INFO: ih-setup is up-to-date
```

This PR changes it to return early when there's an error running `brew
update` or `brew upgrade ih-core`.
  • Loading branch information
pb-dod authored Jan 18, 2024
1 parent 31cb376 commit 15075de
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.42
0.1.43
12 changes: 9 additions & 3 deletions bin/ih-setup
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,26 @@ function ih::private::state::is-step-installed() {
}

function ih::private::upgrade() {

ih::log::info "Checking for updates..."

if ! brew update >/dev/null; then
ih::log::error "brew update failed"
return 1
fi

local OUTDATED
brew update >/dev/null
OUTDATED=$(brew outdated ih-core)
if [ -z "$OUTDATED" ]; then
ih::log::info "ih-setup is up-to-date"
return 0
fi

ih::log::info "Upgrading ih-setup"
if ! brew upgrade ih-core; then
ih::log::error "brew upgrade ih-core failed"
return 1
fi

brew upgrade ih-core || exit 1
ih-setup install
}

Expand Down
2 changes: 1 addition & 1 deletion formula/ih-core.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class IhCore < Formula
VERSION="0.1.42"
VERSION="0.1.43"
desc "Brew formula for installing core tools used at Included Health engineering."
homepage "https://github.com/ConsultingMD/homebrew-ih-public"
license "CC BY-NC-ND 4.0"
Expand Down

0 comments on commit 15075de

Please sign in to comment.