Skip to content

Commit

Permalink
Pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
coverbeck committed Sep 6, 2024
1 parent 08f4c91 commit 1b11435
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void main(String[] args) throws IOException {
// There's a JIRA fix version, but no GitHub milestone, set the GitHub milestone
updateGitHubMilestone(gitHubIssue.getNumber(), fixVersions[0].name());
} else {
LOG.info("The fix version and milestone mismatch must be resolved manually for: {}}", getJiraIssueUrl(issue.jiraIssueId));
LOG.info("The fix version and milestone mismatch must be resolved manually for: {}", getJiraIssueUrl(issue.jiraIssueId));
}
} catch (URISyntaxException | IOException | InterruptedException e) {
LOG.error("Error resolving %s".formatted(issue), e);
Expand Down Expand Up @@ -146,12 +146,6 @@ private static boolean milestoneAndFixVersionMismatch(final GHIssue ghIssue) {
}
}

private static String generateJiraIssuesUrl(final List<MilestoneResolver.JiraAndGithub> issues) {
return "https://ucsc-cgl.atlassian.net/issues/?jql=project=DOCK AND "
+ issues.stream().map(issue -> "key=\"" + issue.jiraIssueId() + "\"")
.collect(Collectors.joining(" or "));
}

private static String getJiraIssueUrl(String issueNumber) {
return "https://ucsc-cgl.atlassian.net/browse/%s".formatted(issueNumber);
}
Expand Down
11 changes: 6 additions & 5 deletions jira_automation/src/main/java/io/dockstore/jira/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.net.http.HttpRequest.Builder;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -67,7 +68,7 @@ public static boolean updateJiraFixVersion(String issueId, String gitHubMileston
final URI uri = getJiraIssueRestUri(issueId);
final UpdateJiraIssue updateJiraIssue = new UpdateJiraIssue(new UpdateFields(
jiraFixVersionFromGitHubMilestone(gitHubMilestone)));
final String json = new Gson().toJson(updateJiraIssue);
final String json = GSON.toJson(updateJiraIssue);
final HttpRequest httpRequest = authorizedRequestBuilder()
.uri(uri)
.PUT(BodyPublishers.ofString(json))
Expand All @@ -94,13 +95,12 @@ public static boolean updateGitHubMilestone(int number, String jiraFixVersion)
.filter(ghMilestone -> ghMilestoneDesc.equals(ghMilestone.getTitle()))
.findFirst();
if (milestone.isEmpty()) {
System.err.println("Could not find GitHub milestone for %s".formatted(jiraFixVersion));
LOG.error("Could not find GitHub milestone for {}", jiraFixVersion);
return false;
}
issue.setMilestone(milestone.get());
} catch (IOException e) {
LOG.error("Error setting milestone on issue %s".formatted(number), e);
System.err.println("Error updating milestone for GitHub issue %s".formatted(number));
return false;
}
return true;
Expand Down Expand Up @@ -141,7 +141,8 @@ private static String getAuthHeaderValue() {
final String username = System.getenv(JIRA_USERNAME);
final String jiraToken = System.getenv(JIRA_TOKEN);
return "Basic %s".formatted(
Base64.getEncoder().encodeToString((username + ':' + jiraToken).getBytes()));
Base64.getEncoder().encodeToString((username + ':' + jiraToken).getBytes(
StandardCharsets.UTF_8)));
}

/**
Expand All @@ -168,7 +169,7 @@ private static String jiraVersionToGitHubMilestone(String jiraVersion) {
} else if (JIRA_OPEN_ENDED_RESEARCH_TASKS.equals(jiraVersion)) {
return GITHUB_OPEN_ENDED_RESEARCH_TASKS;
}
System.err.println("Unexpected jiraVersion: %s".formatted(jiraVersion));
LOG.error("Unexpected jiraVersion: {}", jiraVersion);
return jiraVersion;
}

Expand Down

0 comments on commit 1b11435

Please sign in to comment.