From 3186301a4e97ed5df7964ae3337a61ca4b0e5fc5 Mon Sep 17 00:00:00 2001 From: Andrii Shyshkalov Date: Wed, 8 Feb 2017 11:35:12 +0100 Subject: [PATCH] git cl: allow to forcibly bypass cache and fetch CL description. R=kbr@chromium.org BUG=633572,688765 Change-Id: I2ce6530148bc2f00fe9f6a80aaccc520c69a2f83 Reviewed-on: https://chromium-review.googlesource.com/439186 Commit-Queue: Andrii Shyshkalov Reviewed-by: Kenneth Russell --- git_cl.py | 4 ++-- tests/git_cl_test.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/git_cl.py b/git_cl.py index c860d88be..539ed1d7a 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1355,8 +1355,8 @@ class Changelist(object): return None return '%s/%s' % (self._codereview_impl.GetCodereviewServer(), issue) - def GetDescription(self, pretty=False): - if not self.has_description: + def GetDescription(self, pretty=False, force=False): + if not self.has_description or force: if self.GetIssue(): self.description = self._codereview_impl.FetchDescription() self.has_description = True diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 2f71f4ed9..bf6ba2304 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -173,6 +173,16 @@ class SystemExitMock(Exception): class TestGitClBasic(unittest.TestCase): + def test_get_description(self): + cl = git_cl.Changelist(issue=1, codereview='rietveld', + codereview_host='host') + cl.description = 'x' + cl.has_description = True + cl._codereview_impl.FetchDescription = lambda: 'y' + self.assertEquals(cl.GetDescription(), 'x') + self.assertEquals(cl.GetDescription(force=True), 'y') + self.assertEquals(cl.GetDescription(), 'y') + def _test_ParseIssueUrl(self, func, url, issue, patchset, hostname, fail): parsed = urlparse.urlparse(url) result = func(parsed)