I think what we want is actually branch analysis – we have short-lived feature/bugfix branches and regulary merge back to main. Does this sound like the use case for branch analysis? I think it is but confirmation would be appreciated!
We managed to configure the sonar UI to consider new code:
for main: compare to previous version
for branches: compare to main
Which matches what I believe we need. BUT: we get a warning:
Could not find ref 'main' in refs/heads, refs/remotes, refs/remotes/upstream or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis
which means our git clone is shallow? The build system is a bit opaque so the only way I have found to “unshallow” the code is with exec-maven-plugin . Does this seem like the right path?
So, two questions:
Is branch analysis the right path for short lived branches?
Would git fetch —unshallow be expected to resolve the Could not find ref ‘main’…?
I would actually recommend PR analysis instead. I mean, you can use short-lived branch analysis for this, but the case for it is really subsumed by PR analysis.
These prerequisites are listed for PR analysis, but they really apply to both. Make sure they’re in place and the warning should go away.