Commit 6e9bfb06 authored by Edward Lemur's avatar Edward Lemur Committed by LUCI CQ

git-cl: Remove GetDescriptionFooters and UpdateDescriptionFooters

Unused after https://skia-review.googlesource.com/c/skia/+/265209

Bug: 1042324
Change-Id: I43a04d659e4d851e7b954cdd7dc0525490e3244c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2039969
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 7f6dec01
...@@ -1402,22 +1402,6 @@ class Changelist(object): ...@@ -1402,22 +1402,6 @@ class Changelist(object):
return '\n'.join([wrapper.fill(line) for line in lines]) return '\n'.join([wrapper.fill(line) for line in lines])
return self.description return self.description
def GetDescriptionFooters(self):
"""Returns (non_footer_lines, footers) for the commit message.
Returns:
non_footer_lines (list(str)) - Simple list of description lines without
any footer. The lines do not contain newlines, nor does the list contain
the empty line between the message and the footers.
footers (list(tuple(KEY, VALUE))) - List of parsed footers, e.g.
[("Change-Id", "Ideadbeef...."), ...]
"""
raw_description = self.GetDescription()
msg_lines, _, footers = git_footers.split_footers(raw_description)
if footers:
msg_lines = msg_lines[:len(msg_lines) - 1]
return msg_lines, footers
def GetPatchset(self): def GetPatchset(self):
"""Returns the patchset number as a int or None if not set.""" """Returns the patchset number as a int or None if not set."""
if self.patchset is None and not self.lookedup_patchset: if self.patchset is None and not self.lookedup_patchset:
...@@ -1513,28 +1497,7 @@ class Changelist(object): ...@@ -1513,28 +1497,7 @@ class Changelist(object):
self.description = description self.description = description
self.has_description = True self.has_description = True
def UpdateDescriptionFooters(self, description_lines, footers, force=False):
"""Sets the description for this CL remotely.
You can get description_lines and footers with GetDescriptionFooters.
Args:
description_lines (list(str)) - List of CL description lines without
newline characters.
footers (list(tuple(KEY, VALUE))) - List of footers, as returned by
GetDescriptionFooters. Key must conform to the git footers format (i.e.
`List-Of-Tokens`). It will be case-normalized so that each token is
title-cased.
"""
new_description = '\n'.join(description_lines)
if footers:
new_description += '\n'
for k, v in footers:
foot = '%s: %s' % (git_footers.normalize_name(k), v)
if not git_footers.FOOTER_PATTERN.match(foot):
raise ValueError('Invalid footer %r' % foot)
new_description += foot + '\n'
self.UpdateDescription(new_description, force)
def RunHook(self, committing, may_prompt, verbose, change, parallel): def RunHook(self, committing, may_prompt, verbose, change, parallel):
"""Calls sys.exit() if the hook fails; returns a HookResults otherwise.""" """Calls sys.exit() if the hook fails; returns a HookResults otherwise."""
......
...@@ -173,43 +173,7 @@ class TestGitClBasic(unittest.TestCase): ...@@ -173,43 +173,7 @@ class TestGitClBasic(unittest.TestCase):
cl = git_cl.Changelist(issue=1, codereview_host='host') cl = git_cl.Changelist(issue=1, codereview_host='host')
cl.description = 'x' cl.description = 'x'
cl.has_description = True cl.has_description = True
cl.FetchDescription = lambda *a, **kw: 'y'
self.assertEqual(cl.GetDescription(), 'x') self.assertEqual(cl.GetDescription(), 'x')
self.assertEqual(cl.GetDescription(force=True), 'y')
self.assertEqual(cl.GetDescription(), 'y')
def test_description_footers(self):
cl = git_cl.Changelist(issue=1, codereview_host='host')
cl.description = '\n'.join([
'This is some message',
'',
'It has some lines',
'and, also',
'',
'Some: Really',
'Awesome: Footers',
])
cl.has_description = True
cl.UpdateDescriptionRemote = lambda *a, **kw: 'y'
msg, footers = cl.GetDescriptionFooters()
self.assertEqual(
msg, ['This is some message', '', 'It has some lines', 'and, also'])
self.assertEqual(footers, [('Some', 'Really'), ('Awesome', 'Footers')])
msg.append('wut')
footers.append(('gnarly-dude', 'beans'))
cl.UpdateDescriptionFooters(msg, footers)
self.assertEqual(cl.GetDescription().splitlines(), [
'This is some message',
'',
'It has some lines',
'and, also',
'wut'
'',
'Some: Really',
'Awesome: Footers',
'Gnarly-Dude: beans',
])
def test_set_preserve_tryjobs(self): def test_set_preserve_tryjobs(self):
d = git_cl.ChangeDescription('Simple.') d = git_cl.ChangeDescription('Simple.')
......
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