Skip to content

[JENKINS-75704] Fix Copilot user null name/email handling #864

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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -2572,17 +2572,22 @@
GHUser user = null;
try {
user = pr.getUser();
if (users.containsKey(user.getLogin())) {
// looked up this user already
Copy link
Member

Choose a reason for hiding this comment

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

may as well retain this comment in the else clause

user = users.get(user.getLogin());
String login = user.getLogin();
if ("copilot".equalsIgnoreCase(login)) {

Check warning on line 2576 in src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 2576 is only partially covered, one branch is missing
ContributorMetadataAction contributor =
new ContributorMetadataAction("copilot", "copilot", "copilot@unknown.user");
pullRequestContributorCache.put(number, contributor);
users.put("copilot", user);
} else {

Check warning on line 2581 in src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 2577-2581 are not covered by tests
if (users.containsKey(login)) {
user = users.get(login);
}
ContributorMetadataAction contributor =
new ContributorMetadataAction(login, user.getName(), user.getEmail());
pullRequestContributorCache.put(number, contributor);
users.put(login, user);
}
ContributorMetadataAction contributor =
new ContributorMetadataAction(user.getLogin(), user.getName(), user.getEmail());
pullRequestContributorCache.put(number, contributor);
// store the populated user record now that we have it
Copy link
Member

Choose a reason for hiding this comment

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

ditto

users.put(user.getLogin(), user);
} catch (FileNotFoundException e) {
// If file not found for user, warn but keep going
Copy link
Member

Choose a reason for hiding this comment

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

IIUC this was just false.

request.listener()
.getLogger()
.format(
Expand Down