Commit 90752586 authored by rmistry@google.com's avatar rmistry@google.com

Add support for BUG_PREFIX in codereview.settings.

This change will allow projects other than chromium to specify 'BUG_PREFIX: project_name:' in their codereview.settings file.
Currently, the change is created with 'BUG=', entering a project's bug number there will point it to chromium's issue tracker. Adding a project specific prefix will make the links point to the project's issue tracker without the developer having to know about the magic prefix.

BUG=skia:1983

Review URL: https://codereview.chromium.org/132233006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@244801 0039d316-1c4b-4281-b951-d872f2087c98
parent 3ec0d54f
...@@ -395,6 +395,9 @@ class Settings(object): ...@@ -395,6 +395,9 @@ class Settings(object):
self.viewvc_url = self._GetConfig('rietveld.viewvc-url', error_ok=True) self.viewvc_url = self._GetConfig('rietveld.viewvc-url', error_ok=True)
return self.viewvc_url return self.viewvc_url
def GetBugPrefix(self):
return self._GetConfig('rietveld.bug-prefix', error_ok=True)
def GetDefaultCCList(self): def GetDefaultCCList(self):
return self._GetConfig('rietveld.cc', error_ok=True) return self._GetConfig('rietveld.cc', error_ok=True)
...@@ -865,6 +868,7 @@ def GetCodereviewSettingsInteractively(): ...@@ -865,6 +868,7 @@ def GetCodereviewSettingsInteractively():
SetProperty(settings.GetTreeStatusUrl(error_ok=True), 'Tree status URL', SetProperty(settings.GetTreeStatusUrl(error_ok=True), 'Tree status URL',
'tree-status-url', False) 'tree-status-url', False)
SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True) SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True)
SetProperty(settings.GetBugPrefix(), 'Bug Prefix', 'bug-prefix', False)
# TODO: configure a default branch to diff against, rather than this # TODO: configure a default branch to diff against, rather than this
# svn-based hackery. # svn-based hackery.
...@@ -949,7 +953,7 @@ class ChangeDescription(object): ...@@ -949,7 +953,7 @@ class ChangeDescription(object):
regexp = re.compile(self.BUG_LINE) regexp = re.compile(self.BUG_LINE)
if not any((regexp.match(line) for line in self._description_lines)): if not any((regexp.match(line) for line in self._description_lines)):
self.append_footer('BUG=') self.append_footer('BUG=%s' % settings.GetBugPrefix())
content = gclient_utils.RunEditor(self.description, True, content = gclient_utils.RunEditor(self.description, True,
git_editor=settings.GetGitEditor()) git_editor=settings.GetGitEditor())
if not content: if not content:
...@@ -1032,6 +1036,7 @@ def LoadCodereviewSettingsFromFile(fileobj): ...@@ -1032,6 +1036,7 @@ def LoadCodereviewSettingsFromFile(fileobj):
SetProperty('private', 'PRIVATE', unset_error_ok=True) SetProperty('private', 'PRIVATE', unset_error_ok=True)
SetProperty('tree-status-url', 'STATUS', unset_error_ok=True) SetProperty('tree-status-url', 'STATUS', unset_error_ok=True)
SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True) SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True)
SetProperty('bug-prefix', 'BUG_PREFIX', unset_error_ok=True)
if 'GERRIT_HOST' in keyvals: if 'GERRIT_HOST' in keyvals:
RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']])
......
...@@ -178,6 +178,7 @@ class TestGitCl(TestCase): ...@@ -178,6 +178,7 @@ class TestGitCl(TestCase):
((['git', 'log', '--pretty=format:%s\n\n%b', ((['git', 'log', '--pretty=format:%s\n\n%b',
'fake_ancestor_sha..HEAD'],), 'fake_ancestor_sha..HEAD'],),
'desc\n'), 'desc\n'),
((['git', 'config', 'rietveld.bug-prefix'],), ''),
] ]
@classmethod @classmethod
...@@ -671,6 +672,8 @@ class TestGitCl(TestCase): ...@@ -671,6 +672,8 @@ class TestGitCl(TestCase):
'rietveld.tree-status-url'],), ''), 'rietveld.tree-status-url'],), ''),
((['git', 'config', '--unset-all', ((['git', 'config', '--unset-all',
'rietveld.viewvc-url'],), ''), 'rietveld.viewvc-url'],), ''),
((['git', 'config', '--unset-all',
'rietveld.bug-prefix'],), ''),
((['git', 'config', 'gerrit.host', ((['git', 'config', 'gerrit.host',
'gerrit.chromium.org'],), ''), 'gerrit.chromium.org'],), ''),
# DownloadHooks(False) # DownloadHooks(False)
...@@ -696,6 +699,8 @@ class TestGitCl(TestCase): ...@@ -696,6 +699,8 @@ class TestGitCl(TestCase):
((['git', 'config', 'rietveld.viewvc-url'],), ''), ((['git', 'config', 'rietveld.viewvc-url'],), ''),
(('ViewVC URL:',), ''), (('ViewVC URL:',), ''),
# DownloadHooks(True) # DownloadHooks(True)
((['git', 'config', 'rietveld.bug-prefix'],), ''),
(('Bug Prefix:',), ''),
((commit_msg_path, os.X_OK,), True), ((commit_msg_path, os.X_OK,), True),
] ]
git_cl.main(['config']) git_cl.main(['config'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment