Skip to content
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

Merged
merged 2 commits into from Jul 5, 2017

Conversation

stephenc
Copy link
Member

@stephenc stephenc commented Jul 4, 2017

See JENKINS-41246

@reviewbybees

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();
Copy link
Member

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??

Copy link
Member Author

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

@ghost
Copy link

ghost commented Jul 4, 2017

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();
Copy link
Member

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}) {
Copy link
Member

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()
));
));
Copy link
Member

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());
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gratuitous

@stephenc stephenc merged commit ab97be9 into jenkinsci:master Jul 5, 2017
@stephenc stephenc deleted the jenkins-41246 branch July 5, 2017 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants