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

1085: Gitlab PR has bad link to patch file #1191

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
@@ -549,7 +549,7 @@ private String reviewUsingSkaraHelp() {
}

private String reviewUsingDiffsHelp() {
var diffUrl = pr.repository().webUrl() + "/pull/" + pr.id() + ".diff";
var diffUrl = pr.repository().diffUrl(pr.id());
return "Download this PR as a diff file: \\\n" +
"<a href=\"" + diffUrl + "\">" + diffUrl + "</a>\n";
}
@@ -108,6 +108,11 @@ public URI webUrl(String baseRef, String headRef) {
return null;
}

@Override
public URI diffUrl(String prId) {
return webUrl();
}

@Override
public VCS repositoryType() {
return null;
@@ -64,6 +64,7 @@ PullRequest createPullRequest(HostedRepository target,
URI webUrl(Branch branch);
URI webUrl(Tag tag);
URI webUrl(String baseRef, String headRef);
URI diffUrl(String prId);
VCS repositoryType();
String fileContents(String filename, String ref);
String namespace();
@@ -218,6 +218,12 @@ public URI webUrl(String baseRef, String headRef) {
return gitHubHost.getWebURI(endpoint);
}

@Override
public URI diffUrl(String prId) {
var endpoint = "/" + repository + "/pull/" + prId + ".diff";
return gitHubHost.getWebURI(endpoint);
}

@Override
public VCS repositoryType() {
return VCS.GIT;
@@ -210,6 +210,15 @@ public URI webUrl(String baseRef, String headRef) {
.build();
}

@Override
public URI diffUrl(String prId) {
// GitLab is too smart for it's own best and mangles URLs that contain a
// partial hit with the base MR, hence the double slash.
return URIBuilder.base(gitLabHost.getUri())
.setPath("/" + projectName + "/-/merge_requests//" + prId + ".diff")
.build();
}

@Override
public VCS repositoryType() {
return VCS.GIT;
@@ -146,6 +146,11 @@ public URI webUrl(String baseRef, String headRef) {
return URI.create(url().toString() + "/" + baseRef + "..." + headRef);
}

@Override
public URI diffUrl(String prId) {
return webUrl();
}

@Override
public VCS repositoryType() {
return VCS.GIT;