Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-10222]cleaning out workspace unnecessarily when polling SCM … #249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/main/java/hudson/scm/subversion/UpdateUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* {@link WorkspaceUpdater} that uses "svn update" as much as possible.
Expand Down Expand Up @@ -85,10 +86,10 @@ protected SvnCommandToUse getSvnCommandToUse() throws IOException {
try {
SVNInfo svnInfo = parseSvnInfo(module);

String url = location.getSVNURL().toString();
String wcUrl = svnInfo.getURL().toString();
SVNURL url = location.getSVNURL();
SVNURL wcUrl = svnInfo.getURL();

if (!wcUrl.equals(url)) {
if (!isEqualsRepository(url, wcUrl)) {
if (isSameRepository(location, svnInfo)) {
listener.getLogger().println("Switching from " + wcUrl + " to " + url);
return SvnCommandToUse.SWITCH;
Expand All @@ -109,6 +110,14 @@ protected SvnCommandToUse getSvnCommandToUse() throws IOException {
return SvnCommandToUse.UPDATE;
}

private boolean isEqualsRepository(SVNURL url1, SVNURL url2) {
return Objects.equals(url1.getProtocol(), url2.getProtocol())
&& url1.getPort() == url2.getPort()
&& Objects.equals(url1.getHost(), url2.getHost())
&& Objects.equals(url1.getPath(), url2.getPath())
&& Objects.equals(url1.getUserInfo(), url2.getUserInfo());
}

private boolean isSameRepository(ModuleLocation location, SVNInfo svnkitInfo) throws SVNException {
return location.getSVNURL().toString().startsWith(svnkitInfo.getRepositoryRootURL().toString());
}
Expand Down