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

Unified Diff: git_cl.py

Issue 2400713003: git cl try: refactor to add Gerrit support in the future. (Closed)
Patch Set: Rename. Created 4 years, 2 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 | no next file » | 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 0b8ac7b7c6367faee174fff9d3bb9f40d76b1d77..2fcde04221611aeac7bd5d8ed7b0f4efee99c7da 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1548,6 +1548,10 @@ class Changelist(object):
assert self.GetIssue()
return self._codereview_impl.SetCQState(new_state)
+ def CannotTriggerTryJobReason(self):
+ """Returns reason (str) if unable trigger tryjobs on this CL or None."""
+ return self._codereview_impl.CannotTriggerTryJobReason()
+
# Forward methods to codereview specific implementation.
def CloseIssue(self):
@@ -1690,6 +1694,10 @@ class _ChangelistCodereviewBase(object):
"""
raise NotImplementedError()
+ def CannotTriggerTryJobReason(self):
+ """Returns reason (str) if unable trigger tryjobs on this CL or None."""
+ raise NotImplementedError()
+
class _RietveldChangelistImpl(_ChangelistCodereviewBase):
def __init__(self, changelist, auth_config=None, rietveld_server=None):
@@ -1762,6 +1770,16 @@ class _RietveldChangelistImpl(_ChangelistCodereviewBase):
self._props = self.RpcServer().get_issue_properties(issue, True)
return self._props
+ def CannotTriggerTryJobReason(self):
+ props = self.GetIssueProperties()
+ if not props:
+ return 'Rietveld doesn\'t know about your issue %s' % self.GetIssue()
+ if props.get('closed'):
+ return 'CL %s is closed' % self.GetIssue()
+ if props.get('private'):
+ return 'CL %s is private' % self.GetIssue()
+ return None
+
def GetApprovingReviewers(self):
return get_approving_reviewers(self.GetIssueProperties())
@@ -2716,6 +2734,10 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
gerrit_util.SetReview(self._GetGerritHost(), self.GetIssue(),
labels={'Commit-Queue': vote_map[new_state]})
+ def CannotTriggerTryJobReason(self):
+ # TODO(tandrii): implement for Gerrit.
+ raise NotImplementedError()
+
_CODEREVIEW_IMPLEMENTATIONS = {
'rietveld': _RietveldChangelistImpl,
@@ -4698,12 +4720,9 @@ def CMDtry(parser, args):
# Code below assumes Rietveld issue.
# TODO(tandrii): actually implement for Gerrit http://crbug.com/599931.
- props = cl.GetIssueProperties()
- if props.get('closed'):
- parser.error('Cannot send try jobs for a closed CL')
-
- if props.get('private'):
- parser.error('Cannot use try bots with private issue')
+ error_message = cl.CannotTriggerTryJobReason()
+ if error_message:
+ parser.error('Can\'t trigger try jobs: %s')
if not options.name:
options.name = cl.GetBranch()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698