roll_util: Don't re-add roller account prefix
Sometimes roll CLs themselves get rolled. In those cases don't re-add
"pigweed.infra.roller." to the author domain name—once is enough.
Bug: 595
Change-Id: Iac7868a3d9b2c389b31ff93d80329c85eeb3a0ec
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/77761
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Anthony Fandrianto <atyfto@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/recipe_modules/roll_util/api.py b/recipe_modules/roll_util/api.py
index d522cb4..5145765 100644
--- a/recipe_modules/roll_util/api.py
+++ b/recipe_modules/roll_util/api.py
@@ -309,10 +309,13 @@
def fake_author(self, author):
# Update the author's email address so it can be used for attribution
# without literally attributing it to the author's account in Gerrit.
- return Account(
- author.name,
- '{}@pigweed.infra.roller.{}'.format(*author.email.split('@')),
- )
+ email = author.email
+ prefix = 'pigweed.infra.roller.'
+ if prefix not in email:
+ user, domain = author.email.split('@')
+ email = '{}@{}{}'.format(user, prefix, domain)
+
+ return Account(author.name, email,)
def reviewers(self, *roll):
reviewers = set()