@@ -172,20 +172,25 @@ no_changes_pending || die 'There are uncommitted changes!'
172
172
test -z " $( git ls-files -o --exclude-standard) " ||
173
173
die ' There are untracked files! Please stash them before releasing.'
174
174
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/.*: //' )
178
180
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 "
181
183
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.
183
188
HEAD=" $( git rev-parse HEAD) " &&
184
- git fetch " $REMOTE " master &&
189
+ git fetch " $REMOTE " " $defaultBranch " &&
185
190
FETCH_HEAD=" $( git rev-parse FETCH_HEAD) " &&
186
191
test " $FETCH_HEAD " = HEAD ||
187
192
test " $FETCH_HEAD " = " $( git merge-base $FETCH_HEAD $HEAD ) " ||
188
- die " 'master ' is not up-to-date"
193
+ die " '$defaultBranch ' is not up-to-date"
189
194
190
195
# Ensure license headers are up-to-date.
191
196
test " $SKIP_LICENSE_UPDATE " -o -z " $licenseName " -o " $licenseName " = " N/A" || {
0 commit comments