Skip to content
Permalink
Browse files
forge: add method diffUrl to PullRequest
Reviewed-by: rwestberg
  • Loading branch information
edvbld committed Feb 20, 2020
1 parent 529eedf commit 513a8e3f0a38d0b2d4cc1e5ace06989b5064c963
Showing 6 changed files with 28 additions and 7 deletions.
@@ -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();
@@ -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);
}
@@ -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);
}
@@ -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);
}
@@ -272,4 +272,9 @@ public void setTitle(String title) {
public IssueProject project() {
return null;
}

@Override
public URI diffUrl() {
return null;
}
}
@@ -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
@@ -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");
}
}
@@ -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");
}
}
@@ -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 513a8e3

Please sign in to comment.