Skip to content

Commit

Permalink
Use ls-remote to get default branch
Browse files Browse the repository at this point in the history
Calling GitHub API on macOS without the token hits rate limit
  • Loading branch information
shivammathur committed Dec 19, 2022
1 parent b3a12ce commit 1a42045
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/scripts/tools/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fetch_brew_tap() {
tap_user=$(dirname "$tap")
tap_name=$(basename "$tap")
mkdir -p "$tap_dir/$tap_user"
branch="$(get -s -n "" "https://api.github.com/repos/$tap" | grep default_branch | cut -d: -f 2 | grep -Eo '[^\", ]+' | tr -d '\n')"
branch="$(git ls-remote --symref "https://github.com/$tap" HEAD | grep -Eo 'refs/heads/.*' | tr '\t' '\n' | head -1 | cut -d '/' -f 3)"
get -s -n "" "https://github.com/$tap/archive/$branch.tar.gz" | sudo tar -xzf - -C "$tap_dir/$tap_user"
sudo mv "$tap_dir/$tap_user/$tap_name-$branch" "$tap_dir/$tap_user/$tap_name"
}
Expand Down

0 comments on commit 1a42045

Please # to comment.