Skip to content

Commit

Permalink
feat: use gh to determine default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwremmel committed Jan 22, 2024
1 parent 904ad8c commit 23aa8ed
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -euo pipefail

git config --global --add safe.directory '*'

DEFAULT_BRANCH=(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name)

# for reasons I can't explain, we still need to `git fetch` even with
# `fetch-depth: 0`. Perhaps fetch depth only grabs the history of the current
# SHA and doesn't bother with branch names?
Expand All @@ -12,7 +14,7 @@ git fetch > /dev/null 2> /dev/null
echo 'Fetched full repository from GitHub.'

echo 'Computing merge base.'
MERGE_BASE=$(git merge-base HEAD origin/master)
MERGE_BASE=$(git merge-base HEAD "origin/$DEFAULT_BRANCH")
echo "Found merge base $MERGE_BASE."

if [ "$MERGE_BASE" == "$GITHUB_SHA" ]; then
Expand Down

0 comments on commit 23aa8ed

Please sign in to comment.