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
Improve detection of the target branch #16
Conversation
Nice one, just need to fix the shellcheck warnings :) test -z "$target" && target="$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f 2)" |
If the target branch isn't specified in the command arguments, attempts to find the name of the remotly tracked branch (before falling back on `master`). This means that if the branch `feature` tracks `upstream/dev`, the code will correctly detect that the target branch is `dev`.
@caarlos0 PR updated with the linter warning fixed. |
Thanks @kemenaran 👍 |
@caarlos0 this actually broke the script for me. If I push branch |
@Turbo87 indeed it probably worked before incidentally, because no target branch was specified and That said, if no remote-tracking branch is found, the script is still expected to fallback to |
yes, that is the case.
it's not required, but it would certainly be good if you want to modify the PR again after opening it. then you can just |
Good point. Maybe the part of the script that attempts to infer the target branch could explicitly ignore the remote-tracking branch if it has the same name and remote than the local branch? This would mean the following behavior:
|
hmm, I'm not sure why it would ever target the |
I guess it would be sensible to target the
In both these cases PRs would be made with |
sounds like an uncommon case to me (
in that case I still use |
If the target branch isn't specified in the command arguments, attempts to find the name of the remotly tracked branch (before falling back on
master
).This means that if the branch
feature
tracksupstream/dev
, the code will correctly detect that the target branch isdev
.