Shallow clone of repository if fetch-depth: 0 in the Github

Hello community,
I see a warning message in our project in SonarQube (Data Center Editionv9.9.6 (build 92038)):
“Shallow clone detected during the analysis. Some files will miss SCM information. This will affect features like auto-assignment of issues. Please configure your build to disable shallow clone.”
We checked our GitHub pipeline and see that the action is set according to the documentation. It means:

- uses: actions/checkout@v4
      with:
        fetch-depth: 0
        lfs: true

We checked the SQ source code and this warning is relevant for the method private boolean cloneIsInvalid(File gitBaseDir) of the class CompositeBlameCommand (link). This warning is logged if the condition if (Files.isRegularFile(gitBaseDir.toPath().resolve(“.git/shallow”))) is fulfilled. We haven’t found any .git/shallow file in the system.

Is there anything else we should consider in order to fulfill condition for full clone of repository?

Thank you
Radek

Hey @eset_reset

Everything looks like it should be in order.

Are you sure that fetch-depth: 0 is changed on the branch where you’re running the analysis? Heck, it’s even worth checking to make sure it’s changed in the right workflow file (if you have multiple).

The problem was actually that there was another action after actions/checkout@v4. The action has another actions/checkout@v4 with shallow copy of repository in its implementation. The full copy has been replaced by shallow copy.

1 Like