repo_roller, roll_util: CC authors on roll CLs
CC authors on repo manifest roll CLs.
Bug: 353
Change-Id: I5c27a2b4f9f27f990799b6223c198ec4c39247b2
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/39780
Reviewed-by: Marc-Antoine Ruel <maruel@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
diff --git a/recipe_modules/roll_util/api.py b/recipe_modules/roll_util/api.py
index 56aa090..c78a851 100644
--- a/recipe_modules/roll_util/api.py
+++ b/recipe_modules/roll_util/api.py
@@ -258,7 +258,7 @@
reviewers.update(commit.reviewers)
return reviewers
- def can_cc_on_roll(self, email, host=None):
+ def can_cc_on_roll(self, email, host):
# Assume all queried accounts exist on Gerrit in testing except for
# nobody@google.com.
test_data = self.m.json.test_api.output([{'_account_id': 123}])
@@ -269,6 +269,22 @@
email, 'email:{}'.format(email), host=host, test_data=test_data,
).json.output
+ def include_cc(self, email, cc_domains, host):
+ with self.m.step.nest('cc {}'.format(email)) as pres:
+ domain = email.split('@', 1)[1]
+ if domain.endswith('gserviceaccount.com'):
+ pres.step_summary_text = 'not CCing, robot account'
+ return False
+ if cc_domains and domain not in cc_domains:
+ pres.step_summary_text = 'not CCing, domain excluded'
+ return False
+ if not self.can_cc_on_roll(email, host=host):
+ pres.step_summary_text = 'not CCing, no account in Gerrit'
+ return False
+
+ pres.step_summary_text = 'CCing'
+ return True
+
def _single_commit_roll_message(self, roll):
template = """
[roll {project_name}] {sanitized_message}