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

Conversation

imagejan
Copy link
Member

@imagejan imagejan commented Dec 8, 2020

See #36.

NB: Currently, the remote name origin is hard-coded. We should allow configuration similar to how it is done in release-version.sh.

@ctrueden
Copy link
Member

ctrueden commented Dec 9, 2020

Nice! Here's a way to generalize the name of the remote beyond only origin:

upstreamBranch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
remote=${upstreamBranch%/*}
defaultBranch=$(git remote show "$remote" | grep "HEAD branch" | sed 's/.*: //')

In other words: get the linked remote for the current branch, and assume that's the remote you care about for doing the release. Potential pitfalls:

  1. If the current branch is local only, or not a branch. (The release script should fail in those cases anyway.)
  2. If the current branch is main but of a fork. Then the tests will pass erroneously...

What do you think? I'm concerned about (2) above; maybe we should scrape the intended remote repository out of the pom.xml and then compare it to the list of remotes from git remote? It would be more work, but maybe more reliable.

@imagejan
Copy link
Member Author

imagejan commented Dec 9, 2020

If the current branch is main but of a fork. Then the tests will pass erroneously...

That's the case now already (if you're on master but of a fork), right? In the past this helped me setting up travis for repositories where I didn't have push permission (except the signing keys which failed IIRC), such as several repositories by @tischi where I made pull requests from my fork's master branch, so I wouldn't consider it an issue ;-)

@ctrueden
Copy link
Member

@imagejan OK great, then can you quickly integrate and test my snippet above, and push a commit here if it's good? Then we can merge.

Signed-off-by: Jan Eglinger <jan.eglinger@gmail.com>
@imagejan imagejan marked this pull request as ready for review December 11, 2020 20:12
@imagejan
Copy link
Member Author

@ctrueden thanks! Committed, tested locally, and pushed. This pull request is now ready.

@ctrueden ctrueden merged commit b4c9fe0 into master Dec 14, 2020
@ctrueden ctrueden deleted the generic-default-branches branch December 14, 2020 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants