Skip to content

operations: Fix Go UserMergeBranch failing with ambiguous references

Patrick Steinhardt requested to merge pks-user-merge-branch-ambiguous-ref into master

The UserMergeBranch RPC gets as input the branch name that is to be merged into. This branch name is not fully qualified, so instead of passing in "refs/heads/branch" the user only passes in "branch". We thus need to make sure to convert it into a fully qualified reference, lest any ambiguous reference may cause us to misbehave.

This causes us to mibehave with both Ruby and Go implementations of UserMergeBranch. In Ruby, we silently compute the merge with the tag instead of with the branch as the first parent, which is kind of the worst thing we can do as it silently corrupts data. In Go, we at least raise an error, which is arguably better behaviour compared to silently computing the wrong merge.

This commit introduces a test which would trigger faulty behaviour in both implementations by creating such an ambiguous reference and fixes the bug in the Go implementation. The Ruby fix is likely more involved, which may not be worthwhile to fix considering it's currently being phased out anyway and has been a long standing bug. As such, the bug is simply left as-is.

Merge request reports

Loading