Commit 4b23a2c6 authored by Aaron Gable's avatar Aaron Gable Committed by Commit Bot

Remove more Rietveld support from presubmit

This simplifies future removals of unnecessary code from git-cl.

Bug: 770408
Change-Id: I20329fb6d93b349bf2e9f4aebc795b3f7ef0b646
Reviewed-on: https://chromium-review.googlesource.com/1070588
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: 's avatarMarc-Antoine Ruel <maruel@chromium.org>
parent 0115c356
......@@ -452,36 +452,20 @@ class OutputApi(object):
CQ_INCLUDE_TRYBOTS was updated.
"""
description = cl.GetDescription(force=True)
include_re = re.compile(r'^CQ_INCLUDE_TRYBOTS=(.*)$', re.M | re.I)
trybot_footers = git_footers.parse_footers(description).get(
git_footers.normalize_name('Cq-Include-Trybots'), [])
prior_bots = []
if cl.IsGerrit():
trybot_footers = git_footers.parse_footers(description).get(
git_footers.normalize_name('Cq-Include-Trybots'), [])
for f in trybot_footers:
prior_bots += [b.strip() for b in f.split(';') if b.strip()]
else:
trybot_tags = include_re.finditer(description)
for t in trybot_tags:
prior_bots += [b.strip() for b in t.group(1).split(';') if b.strip()]
for f in trybot_footers:
prior_bots += [b.strip() for b in f.split(';') if b.strip()]
if set(prior_bots) >= set(bots_to_include):
return []
all_bots = ';'.join(sorted(set(prior_bots) | set(bots_to_include)))
if cl.IsGerrit():
description = git_footers.remove_footer(
description, 'Cq-Include-Trybots')
description = git_footers.add_footer(
description, 'Cq-Include-Trybots', all_bots,
before_keys=['Change-Id'])
else:
new_include_trybots = 'CQ_INCLUDE_TRYBOTS=%s' % all_bots
m = include_re.search(description)
if m:
description = include_re.sub(new_include_trybots, description)
else:
description = '%s\n%s\n' % (description, new_include_trybots)
description = git_footers.remove_footer(description, 'Cq-Include-Trybots')
description = git_footers.add_footer(
description, 'Cq-Include-Trybots', all_bots,
before_keys=['Change-Id'])
cl.UpdateDescription(description, force=True)
return [self.PresubmitNotifyResult(message)]
......
......@@ -1461,12 +1461,10 @@ class OutputApiUnittest(PresubmitTestsBase):
self.failIf(output.should_continue())
self.failUnless(output.getvalue().count('???'))
def _testIncludingCQTrybots(self, cl_text, new_trybots, updated_cl_text,
is_gerrit=False):
def _testIncludingCQTrybots(self, cl_text, new_trybots, updated_cl_text):
class FakeCL(object):
def __init__(self, description):
self._description = description
self._is_gerrit = is_gerrit
def GetDescription(self, force=False):
return self._description
......@@ -1474,9 +1472,6 @@ class OutputApiUnittest(PresubmitTestsBase):
def UpdateDescription(self, description, force=False):
self._description = description
def IsGerrit(self):
return self._is_gerrit
def FakePresubmitNotifyResult(message):
return message
......@@ -1499,7 +1494,7 @@ class OutputApiUnittest(PresubmitTestsBase):
self._testIncludingCQTrybots(
"""A change to GPU-related code.
CQ_INCLUDE_TRYBOTS= master.tryserver.blink:linux_trusty_blink_rel ;luci.chromium.try:win_optional_gpu_tests_rel
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel ;luci.chromium.try:win_optional_gpu_tests_rel
""",
[
'luci.chromium.try:linux_optional_gpu_tests_rel',
......@@ -1507,8 +1502,7 @@ CQ_INCLUDE_TRYBOTS= master.tryserver.blink:linux_trusty_blink_rel ;luci.chromium
],
"""A change to GPU-related code.
CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
""")
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel""")
# Starting without any CQ_INCLUDE_TRYBOTS line.
self._testIncludingCQTrybots(
......@@ -1518,14 +1512,14 @@ CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.
'luci.chromium.try:mac_optional_gpu_tests_rel',
],
"""A change to GPU-related code.
CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel
""")
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel""")
# All pre-existing bots are already in output set.
self._testIncludingCQTrybots(
"""A change to GPU-related code.
CQ_INCLUDE_TRYBOTS=luci.chromium.try:win_optional_gpu_tests_rel
Cq-Include-Trybots: luci.chromium.try:win_optional_gpu_tests_rel
""",
[
'luci.chromium.try:linux_optional_gpu_tests_rel',
......@@ -1533,10 +1527,9 @@ CQ_INCLUDE_TRYBOTS=luci.chromium.try:win_optional_gpu_tests_rel
],
"""A change to GPU-related code.
CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
""")
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel""")
# Equivalent tests for Gerrit (pre-existing Change-Id line).
# Equivalent tests with a pre-existing Change-Id line.
self._testIncludingCQTrybots(
"""A change to GPU-related code.
......@@ -1548,7 +1541,7 @@ Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""",
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""", is_gerrit=True)
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""")
self._testIncludingCQTrybots(
"""A change to GPU-related code.
......@@ -1563,7 +1556,7 @@ Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""", is_gerrit=True)
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""")
self._testIncludingCQTrybots(
"""A change to GPU-related code.
......@@ -1579,7 +1572,7 @@ Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_dbg;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""", is_gerrit=True)
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""")
class AffectedFileUnittest(PresubmitTestsBase):
......
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