Skip to content

Commit

Permalink
forge: add method diffUrl to PullRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
edvbld committed Feb 20, 2020
1 parent 5e9d4ad commit 89faf8e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
Expand Up @@ -86,10 +86,6 @@ private static String stats(Repository localRepo, Hash base, Hash head) {
}
}

private static String diffUrl(PullRequest pr) {
return pr.webUrl() + ".diff";
}

private static String fetchCommand(PullRequest pr) {
var repoUrl = pr.repository().webUrl();
return "git fetch " + repoUrl + " " + pr.fetchRef() + ":pull/" + pr.id();
Expand Down Expand Up @@ -151,7 +147,7 @@ static String composeConversationFooter(PullRequest pr, URI issueProject, String
" Webrev: " + webrev + "\n" +
issueString +
" Stats: " + stats(localRepo, base, head) + "\n" +
" Patch: " + diffUrl(pr) + "\n" +
" Patch: " + pr.diffUrl().toString() + "\n" +
" Fetch: " + fetchCommand(pr) + "\n\n" +
composeReplyFooter(pr);
}
Expand All @@ -163,7 +159,7 @@ static String composeRebaseFooter(PullRequest pr, Repository localRepo, URI full
"Changes: " + pr.changeUrl() + "\n" +
" Webrev: " + fullWebrev.toString() + "\n" +
" Stats: " + stats(localRepo, base, head) + "\n" +
" Patch: " + diffUrl(pr) + "\n" +
" Patch: " + pr.diffUrl().toString() + "\n" +
" Fetch: " + fetchCommand(pr) + "\n\n" +
composeReplyFooter(pr);
}
Expand All @@ -179,7 +175,7 @@ static String composeIncrementalFooter(PullRequest pr, Repository localRepo, URI
" - full: " + fullWebrev.toString() + "\n" +
" - incr: " + incrementalWebrev.toString() + "\n\n" +
" Stats: " + stats(localRepo, lastHead, head) + "\n" +
" Patch: " + diffUrl(pr) + "\n" +
" Patch: " + pr.diffUrl().toString() + "\n" +
" Fetch: " + fetchCommand(pr) + "\n\n" +
composeReplyFooter(pr);
}
Expand Down
Expand Up @@ -272,4 +272,9 @@ public void setTitle(String title) {
public IssueProject project() {
return null;
}

@Override
public URI diffUrl() {
return null;
}
}
5 changes: 5 additions & 0 deletions forge/src/main/java/org/openjdk/skara/forge/PullRequest.java
Expand Up @@ -108,6 +108,11 @@ public interface PullRequest extends Issue {
*/
Map<String, Check> checks(Hash hash);

/** Returns a link to the patch/diff file
* @return
*/
URI diffUrl();

/**
* Creates a new check.
* @param check
Expand Down
Expand Up @@ -547,4 +547,9 @@ public void setProperty(String name, JSONValue value) {
public void removeProperty(String name) {
throw new RuntimeException("not implemented yet");
}

@Override
public URI diffUrl() {
return URI.create(webUrl() + ".diff");
}
}
Expand Up @@ -674,4 +674,9 @@ public void setProperty(String name,JSONValue value) {
public void removeProperty(String name) {
throw new RuntimeException("not implemented yet");
}

@Override
public URI diffUrl() {
return URI.create(webUrl() + ".diff");
}
}
Expand Up @@ -212,4 +212,9 @@ public URI webUrl() {
throw new RuntimeException(e);
}
}

@Override
public URI diffUrl() {
return URI.create(webUrl().toString() + ".diff");
}
}

0 comments on commit 89faf8e

Please sign in to comment.