From 8d3348fc7af9d568e0c43fea0beebd203f0a18a0 Mon Sep 17 00:00:00 2001 From: "szager@chromium.org" Date: Tue, 19 Aug 2014 22:49:16 +0000 Subject: [PATCH] Add --with_tags to enable git tag fetching. Needed for chromeos ebuild. BUG=chromium:376027 R=mmoss@chromium.org,hinoka@chromium.org Review URL: https://codereview.chromium.org/490743002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@290683 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient.py | 2 ++ gclient_scm.py | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gclient.py b/gclient.py index eb8b3c399..3e35ebde4 100755 --- a/gclient.py +++ b/gclient.py @@ -1778,6 +1778,8 @@ def CMDsync(parser, args): help='Clone git "branch_heads" refspecs in addition to ' 'the default refspecs. This adds about 1/2GB to a ' 'full checkout. (git only)') + parser.add_option('--with_tags', action='store_true', + help='Clone git tags in addition to the default refspecs.') parser.add_option('-t', '--transitive', action='store_true', help='When a revision is specified (in the DEPS file or ' 'with the command-line flag), transitively update ' diff --git a/gclient_scm.py b/gclient_scm.py index d457a5c5a..acebb0996 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -785,6 +785,8 @@ class GitWrapper(SCMWrapper): # mirror_kwargs['refs'].extend(['refs/tags/lkgr', 'refs/tags/lkcr']) if hasattr(options, 'with_branch_heads') and options.with_branch_heads: mirror_kwargs['refs'].append('refs/branch-heads/*') + if hasattr(options, 'with_tags') and options.with_tags: + mirror_kwargs['refs'].append('refs/tags/*') return git_cache.Mirror(url, **mirror_kwargs) @staticmethod @@ -1075,14 +1077,23 @@ class GitWrapper(SCMWrapper): return self._Capture(['rev-parse', '--verify', 'FETCH_HEAD']) def _UpdateBranchHeads(self, options, fetch=False): - """Adds, and optionally fetches, "branch-heads" refspecs if requested.""" + """Adds, and optionally fetches, "branch-heads" and "tags" refspecs + if requested.""" + need_fetch = fetch if hasattr(options, 'with_branch_heads') and options.with_branch_heads: config_cmd = ['config', 'remote.%s.fetch' % self.remote, '+refs/branch-heads/*:refs/remotes/branch-heads/*', '^\\+refs/branch-heads/\\*:.*$'] self._Run(config_cmd, options) - if fetch: - self._Fetch(options) + need_fetch = True + if hasattr(options, 'with_tags') and options.with_tags: + config_cmd = ['config', 'remote.%s.fetch' % self.remote, + '+refs/tags/*:refs/tags/*', + '^\\+refs/tags/\\*:.*$'] + self._Run(config_cmd, options) + need_fetch = True + if fetch and need_fetch: + self._Fetch(options) def _Run(self, args, options, show_header=True, **kwargs): # Disable 'unused options' warning | pylint: disable=W0613