Skip to content

Commit

Permalink
Revert "Fix PRs without a head URL"
Browse files Browse the repository at this point in the history
This reverts commit f577910.

This broke retrieving PR commits as there is not yet any logic to fetch
the special `/refs/prs/XXXX/head refs that contain the commits in the
base repo. Also the PR head is needed for the branch matching logic in
`determine-source-spec`.
  • Loading branch information
patrickbkr committed Oct 26, 2023
1 parent 3b06c29 commit 7516714
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/DB.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ model GitHubPR is rw is table<github_pr> {
has UInt $.number is column;
has DB::Project $.project is column;
has Str $.base-url is column;
has Str $.head-url is column;
has Str $.head-branch is column;
has Str $.user-url is column;
has DB::PRStatus $.status is column;
Expand Down
8 changes: 4 additions & 4 deletions lib/GitHubCITestRequester.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class PRTask {
has $.title is required;
has PRState $.state is required;
has $.base-url is required;
has $.head-url is required;
has $.head-branch is required;
has $.user-url is required;
has PRCommentTask @.comments;
Expand Down Expand Up @@ -87,6 +88,7 @@ method !process-pr-task(PRTask $pr) {
project => self!repo-to-db-project($pr.repo),
number => $pr.number,
base-url => $pr.base-url,
head-url => $pr.head-url,
head-branch => $pr.head-branch,
user-url => $pr.user-url,
status => DB::OPEN,
Expand Down Expand Up @@ -116,7 +118,7 @@ method !process-pr-commit-task(PRCommitTask $commit) {
DB::CITestSet.^create:
event-type => DB::PR,
:$project,
git-url => $pr.base-url,
git-url => $pr.head-url,
commit-sha => $commit.commit-sha,
user-url => $commit.user-url,
:$pr,
Expand Down Expand Up @@ -274,8 +276,6 @@ method process-worklist() is serial-dedup {
# NOT the head (the repo where the new commits are).
# Using the head repo will not work, as that's usually a different repo where the RCB is
# not installed on and thus has no permissons to add check_runs.
# In addition it's possible there is no head repo. That is the case when the branch or repo a
# PR is based on has been deleted.
# One would think using the base repo can't work, because the commits are not part of that
# repository. But there is some almost completely undocumented behavior in GitHub that copies
# PR commits to the base repo and even creates merge commits (without the PR being merged!).
Expand Down Expand Up @@ -333,7 +333,7 @@ method !determine-source-spec(:$project!, :$git-url!, :$commit-sha!, :$pr --> So
$rakudo-commit-sha, $nqp-commit-sha, $moar-commit-sha);
my $did-things = False;
with $pr {
my %head-data = self!github-url-to-project-repo($pr.base-url);
my %head-data = self!github-url-to-project-repo($pr.head-url);
if $project == DB::RAKUDO && %head-data<repo> eq config.projects.rakudo.repo ||
$project == DB::NQP && %head-data<repo> eq config.projects.nqp.repo ||
$project == DB::MOAR && %head-data<repo> eq config.projects.moar.repo {
Expand Down
2 changes: 2 additions & 0 deletions lib/GitHubInterface.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ method parse-hook-request($event, %json) {
if %json<action> eq 'synchronize'|'opened' {
$!processor.add-task: GitHubCITestRequester::PRTask.new(
repo => %json<pull_request><base><repo><name>,
head-url => %json<pull_request><head><repo><clone_url>,
base-url => %json<pull_request><base><repo><clone_url>,
head-branch => %json<pull_request><head><ref>,
number => %json<pull_request><number>,
Expand Down Expand Up @@ -283,6 +284,7 @@ method retrieve-pulls($project, $repo, :$last-cursor is copy) {
GitHubCITestRequester::PRTask.new:
:$repo,
base-url => %pull-data<baseRepository><url> ~ '.git',
head-url => %pull-data<headRepository><url> ~ '.git',
head-branch => %pull-data<headRefName>,
number => %pull-data<number>,
title => %pull-data<title>,
Expand Down

0 comments on commit 7516714

Please sign in to comment.