Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: git_cl.py

Issue 1873233002: git cl checkout: implement for Gerrit + add test. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@G200-fox
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index 47c646c20a843c0ec853e8ad9ff46f8b710e97ca..ad6fe01a2e0e38437b724c5e4a0fbc8548a73fe7 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1368,8 +1368,12 @@ class _ChangelistCodereviewBase(object):
"""Returns git config setting for the codereview server."""
raise NotImplementedError()
- @staticmethod
- def IssueSetting(branch):
+ @classmethod
+ def IssueSetting(cls, branch):
+ return 'branch.%s.%s' % (branch, cls.IssueSettingPrefix())
+
+ @classmethod
+ def IssueSettingPrefix(cls):
"""Returns name of git config setting which stores issue number for a given
branch."""
raise NotImplementedError()
@@ -1576,9 +1580,9 @@ class _RietveldChangelistImpl(_ChangelistCodereviewBase):
self._auth_config or auth.make_auth_config())
return self._rpc_server
- @staticmethod
- def IssueSetting(branch):
- return 'branch.%s.rietveldissue' % branch
+ @classmethod
+ def IssueSettingPrefix(cls):
+ return 'rietveldissue'
def PatchsetSetting(self):
"""Return the git setting that stores this change's most recent patchset."""
@@ -1717,9 +1721,9 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
self._gerrit_server = 'https://%s' % self._gerrit_host
return self._gerrit_server
- @staticmethod
- def IssueSetting(branch):
- return 'branch.%s.gerritissue' % branch
+ @classmethod
+ def IssueSettingPrefix(cls):
+ return 'gerritissue'
def PatchsetSetting(self):
"""Return the git setting that stores this change's most recent patchset."""
@@ -4532,8 +4536,7 @@ def CMDformat(parser, args):
@subcommand.usage('<codereview url or issue id>')
def CMDcheckout(parser, args):
- """Checks out a branch associated with a given Rietveld issue."""
- # TODO(tandrii): consider adding this for Gerrit?
+ """Checks out a branch associated with a given Rietveld or Gerrit issue."""
_, args = parser.parse_args(args)
if len(args) != 1:
@@ -4546,14 +4549,17 @@ def CMDcheckout(parser, args):
return 1
target_issue = str(issue_arg.issue)
- key_and_issues = [x.split() for x in RunGit(
- ['config', '--local', '--get-regexp', r'branch\..*\.rietveldissue'])
- .splitlines()]
- branches = []
- for key, issue in key_and_issues:
- if issue == target_issue:
- branches.append(re.sub(r'branch\.(.*)\.rietveldissue', r'\1', key))
+ def find_issues(issueprefix):
+ key_and_issues = [x.split() for x in RunGit(
+ ['config', '--local', '--get-regexp', r'branch\..*\.%s' % issueprefix])
+ .splitlines()]
+ for key, issue in key_and_issues:
+ if issue == target_issue:
+ yield re.sub(r'branch\.(.*)\.%s' % issueprefix, r'\1', key)
+ branches = []
+ for cls in _CODEREVIEW_IMPLEMENTATIONS.values():
+ branches.extend(find_issues(cls.IssueSettingPrefix()))
if len(branches) == 0:
print 'No branch found for issue %s.' % target_issue
return 1
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698