Skip to content
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

Checkout + reset confuses SonarQube #159

Open
sandro-h opened this issue Feb 24, 2021 · 0 comments
Open

Checkout + reset confuses SonarQube #159

sandro-h opened this issue Feb 24, 2021 · 0 comments

Comments

@sandro-h
Copy link

Current state

The PR plugin checks out a pull request the following way:

  • Checkout (clone) the master (or default) branch
  • git reset --hard it to the pull request revision

This is causing issues with at least one tool that relies on a reasonable git state: SonarQube. It expects a pull request to be checked out in a separate branch (ideally the PR source branch) and the master to be untouched. See this Sonar community thread where the same issue was observed (and fixed) in CircleCI.

Suggested fix

The plugin could create a local branch first, and then reset that to the pull request revision. This way master remains untouched. I realize depending on Provider (github, gitlab, bitbucket), we don't know the real source branch name, but even just a dummy branch name would fix the problem.

I created a proof of concept here: adnovum@84b46fb

Would you be willing to accept such a change in the form of a pull-request? I see the following open points:

  • The git-cmd library doesn't support creating a new branch, so there's a bit too much boilerplate in the change right now.
  • It uses a dummy branch name gocd-pr/<PR_ID>. This is good enough for us, since we use Bitbucket whose provider doesn't know the source branch anyway. But if you insist, I can make further adjustments to use the source branch if available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant