Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-23054

Gerrit trigger doesn't work well with shallow clones (git --depth=1)

XMLWordPrintable

      In order to speed up clones for very large repositories, I want to be able to use shallow clones.

      Currently, using shallow clones ends up doing the following git commands:

      Cloning repository ssh://gerrit.example.com:29418/myrepo.git
       > git init /a/workspace/engine-copyright-check-gerrit
      Fetching upstream changes from ssh://gerrit.example.com:29418/myrepo.git
       > git --version
       > git fetch --tags --progress ssh://gerrit.example.com:29418/myrepo.git +refs/heads/*:refs/remotes/origin/* --depth=1
       > git config remote.origin.url ssh://gerrit.example.com:29418/myrepo.git
       > git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
       > git config remote.origin.url ssh://gerrit.example.com:29418/myrepo.git
      Fetching upstream changes from ssh://gerrit.example.com:29418/myrepo.git
       > git fetch --tags --progress ssh://gerrit.example.com:29418/myrepo.git refs/changes/40/20740/1
       > git rev-parse FETCH_HEAD^{commit}
      Checking out Revision e976b99ee4a8b6b65ea351f31c5cd4509a5eafaf (origin/release)
       > git config core.sparsecheckout
       > git checkout -f e976b99ee4a8b6b65ea351f31c5cd4509a5eafaf
       > git rev-parse FETCH_HEAD^{commit}
       > git rev-list 0ecf38b5c187d237b3689dcd2d5d52ba8c295610
      

      I expected something more like:

      Cloning repository ssh://gerrit.example.com:29418/myrepo.git
       > git init /a/workspace/engine-copyright-check-gerrit
      Fetching upstream changes from ssh://gerrit.example.com:29418/myrepo.git
       > git --version
       > git fetch --progress ssh://gerrit.example.com:29418/myrepo.git refs/changes/40/20740/1 --depth=1
       > git rev-parse FETCH_HEAD^{commit}
      Checking out Revision e976b99ee4a8b6b65ea351f31c5cd4509a5eafaf (origin/release)
       > git config core.sparsecheckout
       > git checkout -f e976b99ee4a8b6b65ea351f31c5cd4509a5eafaf
       > git rev-parse FETCH_HEAD^{commit}
       > git rev-list 0ecf38b5c187d237b3689dcd2d5d52ba8c295610
      

      The changes are:

      1. Remove --tags flag
      2. Fetch only those specific changes

      The change, for our repository, is massively faster (a few seconds vs. 3 minutes) and less disk space (40mb vs 3gb).

            docwhat Christian Höltje
            docwhat Christian Höltje
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: