UpdateCommand / update

Update scripts for apm, apt, brew, cargo, gem, npm, pip, yum, and more
34 stars 11 forks source link

BUG: bin/update-brew hardcoded for 'master' and doesn't accommodate for newer 'main' branch names #9

Closed mauvehed closed 7 months ago

mauvehed commented 7 months ago

Bug Report

On the current version of the bin/update-brew script, it uses hardcoded references to origin/master and will error on any brew repository that uses main as its primary branch name.

Latest commit where bug occurs: commit 0dae5dd742d12dd06df72f401d003b300d66491f

Current behavior: Output of running bash -x bin/update-brew

$ bash -x bin/update-brew
+ set -euf
+ command -v brew
+++ whoami
++ id -u nate
+ this_uid=501
+++ brew --cellar
++ stat -f %u /opt/homebrew/Cellar
+ brew_uid=501
+ '[' 501 -eq 501 ']'
+ arg_verbose=
+ '[' -n '' ']'
+ arg_debug=
+ '[' -n '' ']'
+ brew cleanup
++ brew tap
+ for tap in '$(brew tap)'
++ brew --repo 1password/tap
+ repo=/opt/homebrew/Library/Taps/1password/homebrew-tap
+ cd /opt/homebrew/Library/Taps/1password/homebrew-tap
+ git clean -dfx
+ git reset --hard origin/master
fatal: ambiguous argument 'origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

We can verify the expected branch name is main here

$ grep -A2 branch /opt/homebrew/Library/Taps/1password/homebrew-tap/.git/config
[branch "main"]
    remote = origin
    merge = refs/heads/main

Expected behavior:

The bin/update-brew script should properly execute regardless of primary branch name and make all updates as normal.

Steps to reproduce:

Executing bin/update-brew against any homebrew tap repository that uses main as its branch name will result in this bug.

Related code:

The relevant commands are on lines 56 and 57

$ grep -inrs master bin/*
bin/update-brew:35:#     git reset --hard origin/master
bin/update-brew:56:            git reset --hard origin/master
bin/update-brew:57:            git pull origin master

Other information:

I will submit and link a PR with a propose fix if needed.

joelparkerhenderson commented 7 months ago

Good catch. Yes a bug. I see your PR coming in next. Thanks!