@@ -172,20 +172,25 @@ no_changes_pending || die 'There are uncommitted changes!'
172172test -z " $( git ls-files -o --exclude-standard) " ||
173173 die ' There are untracked files! Please stash them before releasing.'
174174
175- # Check that we are on the master branch.
176- test refs/heads/master = " $( git rev-parse --symbolic-full-name HEAD) " ||
177- die " Not on 'master' branch"
175+ # Discern default branch.
176+ currentBranch=$( git rev-parse --abbrev-ref --symbolic-full-name HEAD)
177+ upstreamBranch=$( git rev-parse --abbrev-ref --symbolic-full-name @{u})
178+ remote=${upstreamBranch%/* }
179+ defaultBranch=$( git remote show " $remote " | grep " HEAD branch" | sed ' s/.*: //' )
178180
179- # If REMOTE is unset, use origin by default .
180- REMOTE= " ${REMOTE :- origin} "
181+ # Check that we are on the main branch .
182+ test " $currentBranch " = " $defaultBranch " || die " Non-default branch: $currentBranch "
181183
182- # Check that the master branch isn't behind the upstream branch.
184+ # If REMOTE is unset, use branch's upstream remote by default.
185+ REMOTE=" ${REMOTE:- $remote } "
186+
187+ # Check that the main branch isn't behind the upstream branch.
183188HEAD=" $( git rev-parse HEAD) " &&
184- git fetch " $REMOTE " master &&
189+ git fetch " $REMOTE " " $defaultBranch " &&
185190FETCH_HEAD=" $( git rev-parse FETCH_HEAD) " &&
186191test " $FETCH_HEAD " = HEAD ||
187192test " $FETCH_HEAD " = " $( git merge-base $FETCH_HEAD $HEAD ) " ||
188- die " 'master ' is not up-to-date"
193+ die " '$defaultBranch ' is not up-to-date"
189194
190195# Ensure license headers are up-to-date.
191196test " $SKIP_LICENSE_UPDATE " -o -z " $licenseName " -o " $licenseName " = " N/A" || {
0 commit comments