New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIXED JENKINS-41246] Guard against PRs from deleted forks #143
Conversation
this.sourceOwner = pr.getHead().getRepository().getOwnerName(); | ||
this.sourceRepo = pr.getHead().getRepository().getName(); | ||
GHRepository repository = pr.getHead().getRepository(); // may be null for deleted forks JENKINS-41246 | ||
this.sourceOwner = repository.getOwnerName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, did you mean to check for null??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to ascertain reasons about code I wrote more than 15 minutes ago is an exercise in futility... I suspect I did mean to check for null
though... good catch
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
this.sourceRepo = pr.getHead().getRepository().getName(); | ||
GHRepository repository = pr.getHead().getRepository(); // may be null for deleted forks JENKINS-41246 | ||
this.sourceOwner = repository == null ? null : repository.getOwnerName(); | ||
this.sourceRepo = repository == null ? null : repository.getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest marking getters @CheckForNull
.
if (!trusted) { | ||
listener.getLogger().format(" (not from a trusted source)%n"); | ||
} | ||
for (boolean merge : new boolean[] {false, true}) { | ||
for (boolean merge : new boolean[]{false, true}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gratuitous
@@ -671,7 +673,7 @@ private void doRetrieve(SCMSourceCriteria criteria, SCMHeadObserver observer, Ta | |||
user.getLogin(), | |||
user.getName(), | |||
user.getEmail() | |||
)); | |||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gratuitous
@@ -708,10 +710,12 @@ private void doRetrieve(SCMSourceCriteria criteria, SCMHeadObserver observer, Ta | |||
} else { | |||
baseHash = ghPullRequest.getBase().getSha(); | |||
} | |||
PullRequestSCMRevision rev = new PullRequestSCMRevision(head, baseHash, ghPullRequest.getHead().getSha()); | |||
PullRequestSCMRevision rev = | |||
new PullRequestSCMRevision(head, baseHash, ghPullRequest.getHead().getSha()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gratuitous
observer.observe(head, rev); | ||
if (!observer.isObserving()) { | ||
listener.getLogger().format("%n %d pull requests were processed (query completed)%n", pullrequests); | ||
listener.getLogger() | ||
.format("%n %d pull requests were processed (query completed)%n", pullrequests); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gratuitous
See JENKINS-41246
@reviewbybees