-
Notifications
You must be signed in to change notification settings - Fork 136
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
job.py: don't hard-code branch in error-handling #284
base: master
Are you sure you want to change the base?
Conversation
32a9163
to
dda605e
Compare
upd: fixed description |
When MR was created against a branch different from master and ended up with conflicts, bot goes into infinite loop due to getting inside error-handling path a: fatal: invalid reference: master Fix this by not hard-coding the master name. Signed-off-by: Konstantin Kharlamov <[email protected]>
dda605e
to
d0ff9d5
Compare
BTW should this be the target branch of the MR? |
I'm not sure I get it… Should what be the target branch? |
Ah, sorry! In an MR, the source branch is the code you want to merge in, the target branch is the branch you want to merge into. So the MR merges source->target. I was just wondering whether it would be more explicit to use the branch name, which is defined just above your change. So that check would be: if source_branch != 'master':
repo.checkout_branch(target_branch)
repo.remove_branch(source_branch) However, that still hard-codes the branch name In this case, it's not clear whether we are checking that the source branch is not repo.checkout_branch(target_branch)
repo.remove_branch(source_branch) because the source and target are different, by definition. Or, it may be that there's something else going on here. |
Ah, I see, thank you for explanations!
Well, I don't know the code, but from looking at the snippet, I am not sure why couldn't someone add a code to remove the target branch too, unless the target branch is the default one (e.g. usually it is "master", sometimes "main", etc.). In such case we couldn't rely on the target branch name. I don't see any downsides in checking out
I concur with this thought, me neither knows why the check is in place. I found the commit where this line was added, it is 321a867 "Refactor jobs", and it has rewritten a bunch of code. So, I guess git-history in this case wouldn't tell us. But we could ask @JaimeLennox, the author of the commit: did you happen to know, could there be any side-effects if we'd just remove the check for |
Well, the target branch is the one that should receive the changes from the merge request, so probably the user will not want to remove it, and if the target is |
I'd argue for the same reason a user wouldn't want to remove the source branch, and yet marge-bot does it ☺
AFAIK protected branch is not a feature of git (it's a feature of gitlab/github), so removing a branch should not be a problem. In this case it's just a branch that resides locally on a computer, and hopefully reflects the actual branch on the remote server. |
Sorry, I figured it needs elaboration: I mean, the code in question removes source branch on failure to merge it to the target branch. But a user probably will want to merge it eventually, so they wouldn't benefit from removing the branch. But then of course there might be corner cases, such as that a user abandoned the branch and it will be left forever… But a similar thing could be said about the target non-default branch as well ¯\(ツ)/¯ |
Although, now that I think of that, maybe the reason marge-bot even removes the branch is not to free space the branch name takes, but it might be because the way it brings local code up-to-date with the remote is simply by Though, at this point I feel like all that design discussion might be getting offtopic ☺ The PR here is just a fix for a particular problem, no more, no less ☺ |
So, any updates here? I can apply suggested changes if maintainers want so, all I care for now is for the fix to get merged, so we don't have to carry a local patch for the problem. |
When MR was created against a branch different from master and ended up
with conflicts, bot goes into infinite loop due to getting inside
error-handling path a:
Fix this by not hard-coding the master name.
Signed-off-by: Konstantin Kharlamov [email protected]