Git Clone Repository step results in problematic local branch states

The problem:
There is an option to define if the Git Clone Repository step should merge the PR’s source and destination to validate the code state as it will be after the PR merge.
We prefer to have that option set to “yes” as we find this verification very useful.
Currently, the Git Clone Repository step merges the source branch into the destination branch. However, it is also possible to do the opposite - merge the destination into the source branch. Are there any benefits to the first approach?
Although the resulting code should be the same, the problem is the machine’s local destination branch - after the merge, it has the same code as the source branch. When using code analysis tools that analyze differences between source and destination branch in a PR, to that tool, the source and the destination will look the same.
In our case, we have an integration with Sonarqube in PR checks. Sonarqube analyses destination and source branches and compares the differences. Because of Git Clone Repository step behavior (merging source into destination), the destination branch has the same code as the source branch, so there is always no difference. As a result, Sonar always reports success in the PR decoration, as it thinks there were no changes in the PR.

What is the benefit of merging the source branch into the destination, as opposed to merging the destination branch into the source?

Proposal:
Could you introduce an option to merge branches the other way around?
Merging the destination branch into the source branch would produce the same code while keeping the destination branch unaffected. Because of that, tools would be able to compare the branches and detect the changes in the PR.

15 Likes

We implemented our own git clone step as a workaround and this works fine. However, I think it makes sense for this to be fixed in the actual Git Clone Repository step too, so I’d like some feedback from your end.

I have the same problem! I implemented a custom clone script step, but it would be great if this could be an option in Git Clone Repository step so we don’t have to maintain our step just because of that.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.