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

236: Add links to issue in generated webrevs #371

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -23,11 +23,16 @@
package org.openjdk.skara.bots.mlbridge;

import org.openjdk.skara.email.EmailAddress;
import org.openjdk.skara.forge.*;
import org.openjdk.skara.forge.HostedRepository;
import org.openjdk.skara.forge.PullRequest;
import org.openjdk.skara.network.URIBuilder;
import org.openjdk.skara.vcs.*;
import org.openjdk.skara.vcs.Repository;
import org.openjdk.skara.vcs.Hash;
import org.openjdk.skara.webrev.Webrev;
import org.openjdk.skara.version.Version;
import org.openjdk.skara.vcs.openjdk.Issue;
import org.openjdk.skara.jcheck.JCheckConfiguration;
import org.openjdk.skara.issuetracker.IssueTracker;

import java.io.*;
import java.net.URI;
@@ -57,10 +62,26 @@ class WebrevStorage {

private void generate(PullRequest pr, Repository localRepository, Path folder, Hash base, Hash head) throws IOException {
Files.createDirectories(folder);
Webrev.repository(localRepository)
.output(folder)
.version(Version.fromManifest().orElse("unknown"))
.generate(base, head);
var builder = Webrev.repository(localRepository)
.output(folder)
.version(Version.fromManifest().orElse("unknown"));

var issue = Issue.fromString(pr.title());
if (issue.isPresent()) {
var files = localRepository.files(head, List.of(Path.of(".jcheck", "conf")));
if (!files.isEmpty()) {
var conf = JCheckConfiguration.from(localRepository, head);
var project = conf.general().jbs() != null ? conf.general().jbs() : conf.general().project();
var id = issue.get().id();
var issueTracker = IssueTracker.from("jira", URI.create("https://bugs.openjdk.java.net"));
var hostedIssue = issueTracker.project(project).issue(id);
if (hostedIssue.isPresent()) {
builder = builder.issue(hostedIssue.get().webUrl().toString());
}
}
}

builder.generate(base, head);
}

private String generatePlaceholder(PullRequest pr, Hash base, Hash head) {