Commit 4572a091 authored by maruel@chromium.org's avatar maruel@chromium.org

Have Rietveld.get_description() consistently strip CR and whitespace.

This makes the commit description cleaner.

R=iannucci@chromium.org
BUG=

Review URL: https://chromiumcodereview.appspot.com/14061008

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@199275 0039d316-1c4b-4281-b951-d872f2087c98
parent 97170130
......@@ -82,15 +82,20 @@ class Rietveld(object):
self.post("/%d/close" % issue, [('xsrf_token', self.xsrf_token())])
def get_description(self, issue):
"""Returns the issue's description."""
return self.get('/%d/description' % issue)
"""Returns the issue's description.
Converts any CRLF into LF and strip extraneous whitespace.
"""
return '\n'.join(self.get('/%d/description' % issue).strip().splitlines())
def get_issue_properties(self, issue, messages):
"""Returns all the issue's metadata as a dictionary."""
url = '/api/%d' % issue
if messages:
url += '?messages=true'
return json.loads(self.get(url))
data = json.loads(self.get(url))
data['description'] = '\n'.join(data['description'].strip().splitlines())
return data
def get_patchset_properties(self, issue, patchset):
"""Returns the patchset properties."""
......
......@@ -403,11 +403,12 @@ class CachingRietveldTest(BaseFixture):
self.assertEqual(expected, self.rietveld.get_description(1))
def test_get_issue_properties(self):
data = {'description': 'wow\r\nno CR!', 'messages': 'foo'}
self.requests = [
('/api/1?messages=true', rietveld.json.dumps({'messages': 'foo'})),
('/api/1?messages=true', rietveld.json.dumps(data)),
]
expected = {}
expected_msg = {'messages': 'foo'}
expected = {u'description': u'wow\nno CR!'}
expected_msg = {u'description': u'wow\nno CR!', u'messages': u'foo'}
self.assertEqual(expected, self.rietveld.get_issue_properties(1, False))
self.assertEqual(expected_msg, self.rietveld.get_issue_properties(1, True))
......
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