Skip to content

Commit

Permalink
Merge pull request #224 from Joibel/master
Browse files Browse the repository at this point in the history
[Fixed JENKINS-22342] ensure URL normalization correct, retain compatibility
  • Loading branch information
MarkEWaite committed Apr 12, 2014
2 parents 743d715 + a84e48a commit 737e252
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/main/java/hudson/plugins/git/browser/BitbucketWeb.java
Expand Up @@ -24,7 +24,6 @@ public class BitbucketWeb extends GitRepositoryBrowser {
@DataBoundConstructor
public BitbucketWeb(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}

@Override
Expand Down
1 change: 0 additions & 1 deletion src/main/java/hudson/plugins/git/browser/CGit.java
Expand Up @@ -25,7 +25,6 @@ public class CGit extends GitRepositoryBrowser {
@DataBoundConstructor
public CGit(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}

private QueryBuilder param(URL url) {
Expand Down
Expand Up @@ -25,10 +25,9 @@ public class FisheyeGitRepositoryBrowser extends GitRepositoryBrowser {
private static final long serialVersionUID = 2881872624557203410L;

@DataBoundConstructor
public FisheyeGitRepositoryBrowser(String repoUrl) {
public FisheyeGitRepositoryBrowser(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}
}

@Override
public URL getDiffLink(Path path) throws IOException {
Expand Down
Expand Up @@ -30,7 +30,6 @@ public class GitBlitRepositoryBrowser extends GitRepositoryBrowser {
public GitBlitRepositoryBrowser(String repoUrl, String projectName) {
super(repoUrl);
this.projectName = projectName;
this.normalizeUrl = true;
}

@Override
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/hudson/plugins/git/browser/GitLab.java
Expand Up @@ -27,7 +27,6 @@ public class GitLab extends GitRepositoryBrowser {
public GitLab(String repoUrl, String version) {
super(repoUrl);
this.version = Double.valueOf(version);
this.normalizeUrl = true;
}

public double getVersion() {
Expand All @@ -51,9 +50,9 @@ public URL getChangeSetLink(GitChangeSet changeSet) throws IOException {

/**
* Creates a link to the commit diff.
*
*
* https://[GitLab URL]/commits/a9182a07750c9a0dfd89a8461adf72ef5ef0885b#[path to file]
*
*
* @param path
* @return diff link
* @throws IOException
Expand All @@ -67,7 +66,7 @@ public URL getDiffLink(Path path) throws IOException {
/**
* Creates a link to the file.
* https://[GitLab URL]/a9182a07750c9a0dfd89a8461adf72ef5ef0885b/tree/pom.xml
*
*
* @param path
* @return file link
* @throws IOException
Expand Down Expand Up @@ -106,6 +105,6 @@ private String calculatePrefix() {
}

return "commits/";
}
}

}
15 changes: 12 additions & 3 deletions src/main/java/hudson/plugins/git/browser/GitRepositoryBrowser.java
Expand Up @@ -14,7 +14,6 @@
public abstract class GitRepositoryBrowser extends RepositoryBrowser<GitChangeSet> {

private /* mostly final */ String url;
protected boolean normalizeUrl;

@Deprecated
protected GitRepositoryBrowser() {
Expand Down Expand Up @@ -44,7 +43,7 @@ public final URL getUrl() throws IOException {
}
}

if (normalizeUrl) {
if (getNormalizeUrl()) {
return normalizeToEndWithSlash(new URL(u));
}
else {
Expand All @@ -62,7 +61,7 @@ public final URL getUrl() throws IOException {
* @throws IOException
*/
public abstract URL getDiffLink(GitChangeSet.Path path) throws IOException;

/**
* Determines the link to a single file under Git.
* This page should display all the past revisions of this file, etc.
Expand All @@ -74,5 +73,15 @@ public final URL getUrl() throws IOException {
*/
public abstract URL getFileLink(GitChangeSet.Path path) throws IOException;

/**
* Determines whether a URL should be normalized
* Overridden in the rare case where it shouldn't
*
* @return True if the URL should be normalized
*/
protected boolean getNormalizeUrl() {
return true;
}

private static final long serialVersionUID = 1L;
}
6 changes: 5 additions & 1 deletion src/main/java/hudson/plugins/git/browser/GitWeb.java
Expand Up @@ -25,7 +25,11 @@ public class GitWeb extends GitRepositoryBrowser {
@DataBoundConstructor
public GitWeb(String repoUrl) {
super(repoUrl);
this.normalizeUrl = false;
}

@Override
protected boolean getNormalizeUrl() {
return false;
}

@Override
Expand Down
1 change: 0 additions & 1 deletion src/main/java/hudson/plugins/git/browser/GithubWeb.java
Expand Up @@ -33,7 +33,6 @@ public class GithubWeb extends GitRepositoryBrowser {
@DataBoundConstructor
public GithubWeb(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}

@Override
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/hudson/plugins/git/browser/GitoriousWeb.java
Expand Up @@ -24,7 +24,6 @@ public class GitoriousWeb extends GitRepositoryBrowser {
@DataBoundConstructor
public GitoriousWeb(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}

@Override
Expand All @@ -34,9 +33,9 @@ public URL getChangeSetLink(GitChangeSet changeSet) throws IOException {

/**
* Creates a link to the commit diff.
*
*
* https://[Gitorious URL]/commit/a9182a07750c9a0dfd89a8461adf72ef5ef0885b/diffs?diffmode=sidebyside&fragment=1#[path to file]
*
*
* @param path
* @return diff link
* @throws IOException
Expand All @@ -50,7 +49,7 @@ public URL getDiffLink(Path path) throws IOException {
/**
* Creates a link to the file.
* https://[Gitorious URL]/blobs/a9182a07750c9a0dfd89a8461adf72ef5ef0885b/pom.xml
*
*
* @param path
* @return file link
* @throws IOException
Expand Down
1 change: 0 additions & 1 deletion src/main/java/hudson/plugins/git/browser/KilnGit.java
Expand Up @@ -26,7 +26,6 @@ public class KilnGit extends GitRepositoryBrowser {
@DataBoundConstructor
public KilnGit(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}

private QueryBuilder param(URL url) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/hudson/plugins/git/browser/Phabricator.java
Expand Up @@ -27,7 +27,6 @@ public class Phabricator extends GitRepositoryBrowser {
public Phabricator(String repoUrl, String repo) {
super(repoUrl);
this.repo = repo;
this.normalizeUrl = true;
}

public String getRepo() {
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/hudson/plugins/git/browser/RedmineWeb.java
Expand Up @@ -16,7 +16,7 @@

/**
* Git Browser for <a href="http://www.redmine.org/">Redmine</a>.
*
*
* @author mfriedenhagen
*/
public class RedmineWeb extends GitRepositoryBrowser {
Expand All @@ -26,7 +26,6 @@ public class RedmineWeb extends GitRepositoryBrowser {
@DataBoundConstructor
public RedmineWeb(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}

@Override
Expand All @@ -37,9 +36,9 @@ public URL getChangeSetLink(GitChangeSet changeSet) throws IOException {

/**
* Creates a link to the file diff.
*
*
* https://SERVER/PATH/projects/PROJECT/repository/revisions/a9182a07750c9a0dfd89a8461adf72ef5ef0885b/diff/pom.xml
*
*
* Returns a diff link for {@link EditType#DELETE} and {@link EditType#EDIT}, for {@link EditType#ADD} returns an
* {@link #getFileLink}.
*
Expand Down Expand Up @@ -67,7 +66,7 @@ public URL getDiffLink(Path path) throws IOException {
* Creates a link to the file.
* https://SERVER/PATH/projects/PROJECT/repository/revisions/a9182a07750c9a0dfd89a8461adf72ef5ef0885b/entry/pom.xml
* For deleted files just returns a diff link, which will have /dev/null as target file.
*
*
* @param path
* file
* @return file link
Expand Down
1 change: 0 additions & 1 deletion src/main/java/hudson/plugins/git/browser/RhodeCode.java
Expand Up @@ -25,7 +25,6 @@ public class RhodeCode extends GitRepositoryBrowser {
@DataBoundConstructor
public RhodeCode(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}

private QueryBuilder param(URL url) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/hudson/plugins/git/browser/Stash.java
Expand Up @@ -25,7 +25,6 @@ public class Stash extends GitRepositoryBrowser {
@DataBoundConstructor
public Stash(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}

private QueryBuilder param(URL url) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/hudson/plugins/git/browser/ViewGitWeb.java
Expand Up @@ -31,7 +31,6 @@ public class ViewGitWeb extends GitRepositoryBrowser {
public ViewGitWeb(String repoUrl, String projectName) {
super(repoUrl);
this.projectName = projectName;
this.normalizeUrl = true;
}

@Override
Expand Down

0 comments on commit 737e252

Please sign in to comment.