Skip to content

Commit 1b6ef63

Browse files
author
Kraig Amador
committed
link directly to modified files in side by side view
1 parent b15536f commit 1b6ef63

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/main/java/hudson/plugins/git/browser/GitoriousWeb.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public URL getChangeSetLink(GitChangeSet changeSet) throws IOException {
4040
/**
4141
* Creates a link to the commit diff.
4242
*
43-
* https://[Gitorious URL]/commit/a9182a07750c9a0dfd89a8461adf72ef5ef0885b
43+
* https://[Gitorious URL]/commit/a9182a07750c9a0dfd89a8461adf72ef5ef0885b/diffs?diffmode=sidebyside&fragment=1#[path to file]
4444
*
4545
* @param path
4646
* @return diff link
@@ -49,8 +49,7 @@ public URL getChangeSetLink(GitChangeSet changeSet) throws IOException {
4949
@Override
5050
public URL getDiffLink(Path path) throws IOException {
5151
final GitChangeSet changeSet = path.getChangeSet();
52-
// gitorious does not show diffs on single files so we create a link to the commit
53-
return new URL(url, "commit/" + changeSet.getId().toString());
52+
return new URL(url, "commit/" + changeSet.getId().toString() + "/diffs?diffmode=sidebyside&fragment=1#" + path.getPath());
5453
}
5554

5655
/**

src/test/java/hudson/plugins/git/browser/GitoriousWebTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ public void testGetChangeSetLinkGitChangeSet() throws IOException, SAXException
6767
public void testGetDiffLinkPath() throws IOException, SAXException {
6868
final HashMap<String, Path> pathMap = createPathMap("rawchangelog");
6969
final Path modified1 = pathMap.get("src/main/java/hudson/plugins/git/browser/GithubWeb.java");
70-
assertEquals(GITORIOUS_URL + "/commit/396fc230a3db05c427737aa5c2eb7856ba72b05d", gitoriousWeb.getDiffLink(modified1).toString());
70+
assertEquals(GITORIOUS_URL + "/commit/396fc230a3db05c427737aa5c2eb7856ba72b05d/diffs?diffmode=sidebyside&fragment=1#src/main/java/hudson/plugins/git/browser/GithubWeb.java", gitoriousWeb.getDiffLink(modified1).toString());
7171
// For added files returns a link to the commit.
7272
final Path added = pathMap.get("src/test/resources/hudson/plugins/git/browser/rawchangelog-with-deleted-file");
73-
assertEquals(GITORIOUS_URL + "/commit/396fc230a3db05c427737aa5c2eb7856ba72b05d", gitoriousWeb.getDiffLink(added).toString());
73+
assertEquals(GITORIOUS_URL + "/commit/396fc230a3db05c427737aa5c2eb7856ba72b05d/diffs?diffmode=sidebyside&fragment=1#src/test/resources/hudson/plugins/git/browser/rawchangelog-with-deleted-file", gitoriousWeb.getDiffLink(added).toString());
7474
}
7575

7676
/**
@@ -94,7 +94,7 @@ public void testGetFileLinkPathForDeletedFile() throws IOException, SAXException
9494
final HashMap<String,Path> pathMap = createPathMap("rawchangelog-with-deleted-file");
9595
final Path path = pathMap.get("bar");
9696
final URL fileLink = gitoriousWeb.getFileLink(path);
97-
assertEquals(GITORIOUS_URL + "/commit/fc029da233f161c65eb06d0f1ed4f36ae81d1f4f", String.valueOf(fileLink));
97+
assertEquals(GITORIOUS_URL + "/commit/fc029da233f161c65eb06d0f1ed4f36ae81d1f4f/diffs?diffmode=sidebyside&fragment=1#bar", String.valueOf(fileLink));
9898
}
9999

100100
private GitChangeSet createChangeSet(String rawchangelogpath) throws IOException, SAXException {

0 commit comments

Comments
 (0)