4

Our code is hosted on GitHub. We are using Google Cloud Container Builder in order to build and package our software. In order to do that, we had to connect our private repo to Google Cloud Source Repository. Unfortunately it seems that the mirror is a shallow clone, because our dev tools are complaining about it. e.g. SonarQube cannot fetch blame for certain files.

Documentation:

Connected repositories

If you already have a repository on GitHub or Bitbucket, you can connect it to your Cloud Source Repository. Connected repositories are synchronized with the Cloud Source Repository automatically.

Is there a way how to increase the depth of the clone? Or how to make a full clone?

Michal
  • 15,429
  • 10
  • 73
  • 104
  • How are you seeing this error, Michal? Are you pointing SonarQube at GitHub or CSR? You should be pointing it at GitHub. – csells Oct 23 '17 at 16:48
  • @csells it's part of a Gradle build. We're using the Gradle SonarQube plugin. We currently mitigated the problem by `sonar.scm.disabled=true`, but that's fixing by getting rid of some SonarQube functionality... – Michal Oct 23 '17 at 17:10
  • I'm still confused -- are you pointing your Gradle SonarQube plugin at a clone from GitHub or CSR? – csells Oct 24 '17 at 19:28
  • @csells we're not pointing it at a repository. It's a build step in CI. The code is in GitHub, on push it then gets cloned to CSR, then gets copied into a container where it's built. During the build process we call `gradle sonarqube ... -Dsonar.scm.disabled=true`. Not pointing it on anything. It's setup in cloudbuild.yml using cloud container builder. – Michal Oct 25 '17 at 08:24

2 Answers2

4

As described here

To build your source on a Git repo, Cloud Build performs a shallow clone of the repo. This means that only the single commit that started the build is checked out in the workspace to build. Cloud Build does not check out any other branches or history. This is done for efficiency, so that builds don't have to wait to fetch the whole repository and history just to build a single commit.

If you want to include more of your repo's history in the build, add a build step in your build config file to "unshallow" the clone. For example

steps:
- name: gcr.io/cloud-builders/git
  args: ['fetch', '--unshallow']
...
ALOToverflow
  • 2,679
  • 5
  • 36
  • 70
1

Google Cloud Source Repository only supports full clones. Your repository does contain the full history for all branches (refs/heads/*) and tags (refs/tags/*).

If a commit is missing, my first guess is the commit is only found under a namespace such as refs/pulls/*, which CSR does not mirror.

  • Hi Shawn, thanks for your answer. We don't have any "git magic" in our repo. Just one branch from which we make feature branches that (when done) get merge squashed into master. Team of 2 (1 codes, the other reviews and merges). Do you see any problem in that? Can that be addressed in any way? – Michal Oct 22 '17 at 17:33