Skip to content

Commit b4c9fe0

Browse files
authored
Merge pull request #38 from scijava/generic-default-branches
travisify.sh: respect default branch name
2 parents 6d8c498 + b812833 commit b4c9fe0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

travisify.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ process() {
8282
esac
8383
git fetch >/dev/null
8484
git diff-index --quiet HEAD -- || die "Dirty working copy"
85-
branch=$(git rev-parse --abbrev-ref HEAD)
86-
test "$branch" = "master" || die "Non-master branch: $branch"
85+
currentBranch=$(git rev-parse --abbrev-ref HEAD)
86+
upstreamBranch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
87+
remote=${upstreamBranch%/*}
88+
defaultBranch=$(git remote show "$remote" | grep "HEAD branch" | sed 's/.*: //')
89+
test "$currentBranch" = "$defaultBranch" || die "Non-default branch: $currentBranch"
8790
git merge --ff --ff-only 'HEAD@{u}' >/dev/null ||
8891
die "Cannot fast forward (local diverging?)"
8992
# test "$(git rev-parse HEAD)" = "$(git rev-parse 'HEAD@{u}')" ||
@@ -124,7 +127,7 @@ language: java
124127
jdk: openjdk8
125128
branches:
126129
only:
127-
- master
130+
- $defaultBranch
128131
- "/.*-[0-9]+\\\\..*/"
129132
install: true
130133
script: "$travisBuildScript"

0 commit comments

Comments
 (0)