Skip to content

travisify.sh: respect default branch name #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions travisify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ process() {
esac
git fetch >/dev/null
git diff-index --quiet HEAD -- || die "Dirty working copy"
branch=$(git rev-parse --abbrev-ref HEAD)
test "$branch" = "master" || die "Non-master branch: $branch"
currentBranch=$(git rev-parse --abbrev-ref HEAD)
upstreamBranch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
remote=${upstreamBranch%/*}
defaultBranch=$(git remote show "$remote" | grep "HEAD branch" | sed 's/.*: //')
test "$currentBranch" = "$defaultBranch" || die "Non-default branch: $currentBranch"
git merge --ff --ff-only 'HEAD@{u}' >/dev/null ||
die "Cannot fast forward (local diverging?)"
# test "$(git rev-parse HEAD)" = "$(git rev-parse 'HEAD@{u}')" ||
Expand Down Expand Up @@ -124,7 +127,7 @@ language: java
jdk: openjdk8
branches:
only:
- master
- $defaultBranch
- "/.*-[0-9]+\\\\..*/"
install: true
script: "$travisBuildScript"
Expand Down