Permalink
Browse files

[FIXED JENKINS-11887] Cleanup code comments, checked successful test …

…execution
  • Loading branch information...
Gerd Zanker Gerd Zanker
Gerd Zanker authored and Gerd Zanker committed Jan 3, 2012
1 parent d69d608 commit c9439100a4f9e8e8ca2fbc330237063797572c0f
@@ -9,7 +9,6 @@
import hudson.scm.ChangeLogSet;
import hudson.scm.EditType;
import hudson.scm.RepositoryBrowser;
-import hudson.scm.SubversionRepositoryBrowser;
import hudson.scm.browsers.QueryBuilder;
import java.io.IOException;
@@ -19,7 +18,9 @@
import org.kohsuke.stapler.DataBoundConstructor;
/**
- * {@link SubversionRepositoryBrowser} that produces Trac links.
+ * {@link GitRepositoryBrowser} that produces Trac links.
+ *
+ * @author Gerd Zanker (gerd.zanker@web.de)
*/
public class TracGitRepositoryBrowser extends GitRepositoryBrowser {
@@ -48,14 +49,15 @@ protected URL getTracWebURL(GitChangeSet changeSet) throws MalformedURLException
@Override
public URL getDiffLink(Path path) throws IOException {
- // normally the diffs of a changeset are shown on one Trac HTML page and use the pattern
- // <url>"/changeset/"<changesetID>"#file"<NoOfFileInChangeset>
- // BUt because the git changeset doesn't return an order list (only a HashSet)
- // it is not possible to get correct index for the file inside the changeset
-
+ // Normally the diffs of a changeset are shown on one single Trac HTML page
+ // and use the pattern <url>"/changeset/"<changesetID>"#file"<NoOfFileInChangeset>
+ // But because the git changeset doesn't return an order list (only a HashSet)
+ // it is not possible to get correct index for the file inside the changeset.
+ // see https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitChangeSet.java#L57
+
// Therefore a different URL pattern is used to show only the diff of a single file.
// returns <url>"/changeset/"<changesetID>/<file>
- // The drawback is that the user has to navigate and not only to scroll to see other diffs.
+ // The drawback is 'only' that the user has to navigate and not only to scroll to see other diffs.
// Instead of https://fedorahosted.org/eclipse-fedorapackager/changeset/0956859f7db2656cae445488689a214c104bf1b3#file3
// e.g. https://fedorahosted.org/eclipse-fedorapackager/changeset/0956859f7db2656cae445488689a214c104bf1b3/org.fedoraproject.eclipse.packager.rpm/src/org/fedoraproject/eclipse/packager/rpm/internal/handlers/SRPMImportHandler.java
@@ -65,7 +67,6 @@ public URL getDiffLink(Path path) throws IOException {
return null;
}
-
@Override
public URL getFileLink(Path path) throws IOException {
// returns <url>"/browser/"<file>"$rev="<changsetID>
@@ -17,16 +17,26 @@
import org.xml.sax.SAXException;
/**
+ * Tests for TracGitRepositoryBrowser
+ *
* @author Gerd Zanker (gerd.zanker@web.de)
*
* Based on the ViewGetWeb code from
* @author Paul Nyheim (paul.nyheim@gmail.com)
*/
public class TracGitRepositoryBrowserTest extends TestCase {
+ /**
+ * URL used for testing
+ */
private static final String TRAC_URL = "https://trac";
- private final TracGitRepositoryBrowser tracGitBrowser = new TracGitRepositoryBrowserMock();
-
+
+ /**
+ * TracGitRepositoryBrowser instance used for testing.
+ * The getTracWebURL function is mocked to easily return the testing URL.
+ */
+ private final TracGitRepositoryBrowser tracGitBrowser = new TracGitRepositoryBrowserMock();
+
/**
* Mock implementation to return the test URL.
*/
@@ -57,8 +67,7 @@ public void testGetChangeSetLinkGitChangeSet() throws IOException, SAXException
/**
* Test method for
* {@link hudson.plugins.git.browser.TracGitBrowser#getDiffLink(hudson.plugins.git.GitChangeSet.Path)}.
- * Test cases where links are tested, leading to the same changeset page as above, but using anchors.
- * The anchors are the diff sections for each file inside the changeset.
+ * Test cases where links are tested, leading to the diff of the file from the same changeset page as above.
*
* @throws SAXException
* @throws IOException
@@ -123,7 +132,14 @@ public void testGetFileLinkPathForDeletedFile() throws IOException, SAXException
}
-
+ /**
+ * Helper to create a changeset for testing.
+ *
+ * @param rawchangelogpath
+ * @return
+ * @throws IOException
+ * @throws SAXException
+ */
private GitChangeSet createChangeSet(String rawchangelogpath) throws IOException, SAXException {
final File rawchangelog = new File(TracGitRepositoryBrowserTest.class.getResource(rawchangelogpath).getFile());
final GitChangeLogParser logParser = new GitChangeLogParser(false);
@@ -132,6 +148,14 @@ private GitChangeSet createChangeSet(String rawchangelogpath) throws IOException
}
+ /**
+ * Helper to create a map of paths.
+ *
+ * @param changelog
+ * @return
+ * @throws IOException
+ * @throws SAXException
+ */
private HashMap<String, Path> createPathMap(final String changelog) throws IOException, SAXException {
final HashMap<String, Path> pathMap = new HashMap<String, Path>();
final Collection<Path> changeSet = createChangeSet(changelog).getPaths();

0 comments on commit c943910

Please sign in to comment.