Skip to content

Commit

Permalink
fix(cot): don't use parent repo when evaluating pull request json-e c…
Browse files Browse the repository at this point in the history
…ontext on forks

Issue: mozilla-releng#645
  • Loading branch information
ahal committed Apr 26, 2024
1 parent cd0aac0 commit 54d0329
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/scriptworker/cot/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,6 @@ async def _get_additional_github_pull_request_jsone_context(decision_link):
token = context.config["github_oauth_token"]

github_repo = GitHubRepository(repo_owner, repo_name, token)
repo_definition = github_repo.definition

if repo_definition["fork"]:
github_repo = GitHubRepository(owner=repo_definition["parent"]["owner"]["login"], repo_name=repo_definition["parent"]["name"], token=token)

pull_request_data = await github_repo.get_pull_request(pull_request_number)
# Even though pull_request_data['head']['repo']['pushed_at'] does exist,
Expand Down
10 changes: 2 additions & 8 deletions tests/test_cot_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,11 +1205,9 @@ async def test_get_additional_git_action_jsone_context(github_action_link):
}


@pytest.mark.parametrize("is_fork", (True, False))
@pytest.mark.asyncio
async def test_populate_jsone_context_github_pull_request(mocker, mobile_chain_pull_request, mobile_github_pull_request_link, is_fork):
async def test_populate_jsone_context_github_pull_request(mocker, mobile_chain_pull_request, mobile_github_pull_request_link):
github_repo_mock = MagicMock()
github_repo_mock.definition = {"fork": True, "parent": {"name": "firefox-android", "owner": {"login": "mozilla-mobile"}}} if is_fork else {"fork": False}

async def get_pull_request_mock(pull_request_number, *args, **kwargs):
assert pull_request_number == 1234
Expand Down Expand Up @@ -1241,11 +1239,7 @@ async def get_pull_request_mock(pull_request_number, *args, **kwargs):

github_repo_class_mock.assert_any_call("JohanLorenzo", "firefox-android", "fakegithubtoken")

if is_fork:
github_repo_class_mock.assert_any_call(owner="mozilla-mobile", repo_name="firefox-android", token="fakegithubtoken")
assert len(github_repo_class_mock.call_args_list) == 2
else:
assert len(github_repo_class_mock.call_args_list) == 1
assert len(github_repo_class_mock.call_args_list) == 1

del context["as_slugid"]
assert context == {
Expand Down

0 comments on commit 54d0329

Please sign in to comment.