Skip to content
Permalink
Browse files

[Fix JENKINS-17117] Include parent SHA1 in RhodeCode browser diff URL

  • Loading branch information
MarkEWaite committed Jul 18, 2015
1 parent 91298be commit 05c5b1af187f03540e3936323eed4ffb6767f8cd
@@ -12,7 +12,6 @@
import org.kohsuke.stapler.StaplerRequest;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

/**
@@ -57,12 +56,7 @@ public URL getChangeSetLink(GitChangeSet changeSet) throws IOException {
public URL getDiffLink(Path path) throws IOException {
GitChangeSet changeSet = path.getChangeSet();
URL url = getUrl();

if (path.getEditType() == EditType.DELETE) {
return new URL(url, url.getPath() + "diff/" + path.getPath() + param(url).add("diff2=" + changeSet.getParentCommit()).add("diff1=" + changeSet.getId()).toString() + "&diff=diff+to+revision");
} else {
return new URL(url, url.getPath() + "diff/" + path.getPath() + param(url).add("diff2=" + changeSet.getId()).add("diff1=" + changeSet.getId()).toString() + "&diff=diff+to+revision");
}
return new URL(url, url.getPath() + "diff/" + path.getPath() + param(url).add("diff2=" + changeSet.getParentCommit()).add("diff1=" + changeSet.getId()).toString() + "&diff=diff+to+revision");
}

/**
@@ -62,10 +62,10 @@ public void testGetChangeSetLinkGitChangeSet() throws IOException, SAXException
public void testGetDiffLinkPath() throws IOException, SAXException {
final HashMap<String, Path> pathMap = createPathMap("rawchangelog");
final Path modified1 = pathMap.get("src/main/java/hudson/plugins/git/browser/GithubWeb.java");
assertEquals(RHODECODE_URL + "/diff/src/main/java/hudson/plugins/git/browser/GithubWeb.java?diff2=396fc230a3db05c427737aa5c2eb7856ba72b05d&diff1=396fc230a3db05c427737aa5c2eb7856ba72b05d&diff=diff+to+revision", rhodecode.getDiffLink(modified1).toString());
assertEquals(RHODECODE_URL + "/diff/src/main/java/hudson/plugins/git/browser/GithubWeb.java?diff2=f28f125f4cc3e5f6a32daee6a26f36f7b788b8ff&diff1=396fc230a3db05c427737aa5c2eb7856ba72b05d&diff=diff+to+revision", rhodecode.getDiffLink(modified1).toString());
// For added files returns a link to the commit.
final Path added = pathMap.get("src/main/java/hudson/plugins/git/browser/GithubWeb.java");
assertEquals(RHODECODE_URL + "/diff/src/main/java/hudson/plugins/git/browser/GithubWeb.java?diff2=396fc230a3db05c427737aa5c2eb7856ba72b05d&diff1=396fc230a3db05c427737aa5c2eb7856ba72b05d&diff=diff+to+revision", rhodecode.getDiffLink(added).toString());
assertEquals(RHODECODE_URL + "/diff/src/main/java/hudson/plugins/git/browser/GithubWeb.java?diff2=f28f125f4cc3e5f6a32daee6a26f36f7b788b8ff&diff1=396fc230a3db05c427737aa5c2eb7856ba72b05d&diff=diff+to+revision", rhodecode.getDiffLink(added).toString());
}

/**

0 comments on commit 05c5b1a

Please sign in to comment.
You can’t perform that action at this time.