Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions bot/code_review_bot/revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class Revision(object):
def __init__(self, api, try_task, update_build=True):
assert isinstance(api, PhabricatorAPI)
assert isinstance(try_task, dict)
self.repository = None
self.repository = None # a try repo where the revision is stored
self.target_repository = None # the target repo where the patch may land
self.files = []
self.lines = {}
self.patch = None
Expand Down Expand Up @@ -300,12 +301,14 @@ def is_decision_task(task):
if decision_env.get("GECKO_HEAD_REPOSITORY") == REPO_GECKO_TRY:
# Mozilla-Central Try
self.mercurial_revision = decision_env.get("GECKO_HEAD_REV")
self.repository = "mozilla-central"
self.repository = "try"
self.target_repository = "mozilla-central"

elif decision_env.get("NSS_HEAD_REPOSITORY") == REPO_NSS_TRY:
# NSS Try
self.mercurial_revision = decision_env.get("NSS_HEAD_REVISION")
self.repository = "nss"
self.repository = "nss-try"
self.target_repository = "nss"

else:
raise Exception("Unsupported decision task")
Expand All @@ -328,4 +331,8 @@ def as_dict(self):
# Extra infos for frontend
"title": self.revision["fields"].get("title"),
"bugzilla_id": self.revision["fields"].get("bugzilla.bug-id"),
# Extra infos for backend
"repository": self.repository,
"target_repository": self.target_repository,
"mercurial_revision": self.mercurial_revision,
}
3 changes: 2 additions & 1 deletion bot/code_review_bot/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def index(self, revision, **kwargs):
payload["try_group_id"] = settings.try_group_id

# Always add the repository we are working on
payload["repository"] = revision.repository
# This is mainly used by the frontend to list & filter diffs
payload["repository"] = revision.target_repository

# Add restartable flag for monitoring
payload["monitoring_restart"] = payload["state"] == "error" and payload.get(
Expand Down
22 changes: 22 additions & 0 deletions bot/tests/test_reporter_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ def test_publication(tmpdir, mock_issues, mock_revision):
"""
from code_review_bot.report.debug import DebugReporter

# Load description from Taskcluster tasks
mock_revision.setup_try(
{
# Base information are retrieved from the decision task
"decision": {
"task": {
"payload": {
"image": "taskcluster/decision",
"env": {
"GECKO_HEAD_REV": "deadc0ffee",
"GECKO_HEAD_REPOSITORY": "https://hg.mozilla.org/try",
"GECKO_BASE_REPOSITORY": "https://hg.mozilla.org/mozilla-central",
},
}
}
}
}
)

report_dir = str(tmpdir.mkdir("public").realpath())
report_path = os.path.join(report_dir, "report.json")
assert not os.path.exists(report_path)
Expand All @@ -36,6 +55,9 @@ def test_publication(tmpdir, mock_issues, mock_revision):
"phid": "PHID-DREV-zzzzz",
"title": "Static Analysis tests",
"has_clang_files": False,
"repository": "try",
"target_repository": "mozilla-central",
"mercurial_revision": "deadc0ffee",
}

assert "time" in report
Expand Down
2 changes: 1 addition & 1 deletion bot/tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MockRevision(Revision):
def __init__(self, namespaces, details, repository):
self._namespaces = namespaces
self._details = details
self.repository = repository
self.target_repository = repository

@property
def namespaces(self):
Expand Down