Skip to content

Commit

Permalink
JENKINS-22342 ensure URL normalization correct
Browse files Browse the repository at this point in the history
Previous attempts to fix this stored the normalization flag
in the serialized repository browser. Moved to be a function
call to avoid the deserializer getting involved
  • Loading branch information
Alan Clucas committed Apr 11, 2014
1 parent 743d715 commit 510337b
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 22 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 @@ -27,7 +27,6 @@ public class FisheyeGitRepositoryBrowser extends GitRepositoryBrowser {
@DataBoundConstructor
public FisheyeGitRepositoryBrowser(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}

@Override
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
1 change: 0 additions & 1 deletion 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 Down
17 changes: 11 additions & 6 deletions src/main/java/hudson/plugins/git/browser/GitRepositoryBrowser.java
Expand Up @@ -14,11 +14,6 @@
public abstract class GitRepositoryBrowser extends RepositoryBrowser<GitChangeSet> {

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

@Deprecated
protected GitRepositoryBrowser() {
}

protected GitRepositoryBrowser(String repourl) {
this.url = repourl;
Expand All @@ -44,7 +39,7 @@ public final URL getUrl() throws IOException {
}
}

if (normalizeUrl) {
if (getNormalizeUrl()) {
return normalizeToEndWithSlash(new URL(u));
}
else {
Expand Down Expand Up @@ -74,5 +69,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
1 change: 0 additions & 1 deletion 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 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
5 changes: 2 additions & 3 deletions src/main/java/hudson/plugins/git/browser/RedmineWeb.java
Expand Up @@ -26,7 +26,6 @@ public class RedmineWeb extends GitRepositoryBrowser {
@DataBoundConstructor
public RedmineWeb(String repoUrl) {
super(repoUrl);
this.normalizeUrl = true;
}

@Override
Expand All @@ -42,8 +41,8 @@ public URL getChangeSetLink(GitChangeSet changeSet) throws IOException {
*
* Returns a diff link for {@link EditType#DELETE} and {@link EditType#EDIT}, for {@link EditType#ADD} returns an
* {@link #getFileLink}.
*
*
*
*
* @param path
* affected file path
* @return diff 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 510337b

Please sign in to comment.