craft: Last step of publish is selecting the wrong merge target
After a release we merge the release branch back to the base branch:
Unfortunately it looks like our algorithm for determining which branch to merge into if not explicitly provided is wrong. The past two sentry releases have merged back into the wrong branch:
https://github.com/getsentry/publish/runs/4218472116?check_suite_focus=true#step:8:123 → https://github.com/getsentry/sentry/commit/9ae170c4b3b2fd608caabb37e9ce08281d5e4747
https://github.com/getsentry/publish/runs/3909141316?check_suite_focus=true#step:8:666 → https://github.com/getsentry/sentry/commit/b15920f0c741c35f70dab85b3b2b76ffa0317602
The result is that (at least) the CHANGES file in the sentry repo has not been updated since 21.9.0 … we’re missing all of the new changelog-y goodness!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 20 (20 by maintainers)
I might have a solution to this. Depending on whether I can get to it, I will try to push up a PR and test this locally.
For background: The current approach searches the current branches history for branch annotations. This assumes that the base branch has not moved in the meanwhile, e.g.
masterstill points to a direct ancestor.My idea is based on https://stackoverflow.com/a/17843908. Instead, use
git show-branchto search for the nearest ancestor commit (marked with a*) that resides in a different branch. Example borrowed from the stack overflow answer with the relevant ancestor commit marked:@jan-auer I chose the current method in https://stackoverflow.com/a/55238339/90297 due to the reasons they listed under “Why did not show-branch work for me”. I did not encounter them but the last case kind of looked possible (develop vs master for hotfixes). I think we can try the other approach and see if it actually gives us any headaches.
We just hit this same bug with
sentry-native, see https://github.com/getsentry/publish/issues/694#issuecomment-997978039The culprit here is the following:
masterbranchgit log --decorate --simplify-by-decoration --oneline, which doesn’t see the branch pointI haven’t had the chance to look into this much further. We would basically need to find the branching point rather than searching for refs in the log. Same when the base branch moves on in the meanwhile, which is what happened for the Sentry release.
Thinking of this again, since the issue is master moving too quickly, I think another
pullright before trying to determine the target should fix the issue mostly?That’s more along the lines of what I was thinking. Basically any option that craft accepts on the command line should be available through the config file.