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-45362] Workaround for not detecting changes in externals #191

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
53 changes: 50 additions & 3 deletions src/main/java/jenkins/scm/impl/subversion/SubversionSCMSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNNodeKind;
Expand Down Expand Up @@ -126,6 +128,8 @@ public class SubversionSCMSource extends SCMSource {
private String includes = DescriptorImpl.DEFAULT_INCLUDES;

private String excludes = DescriptorImpl.DEFAULT_EXCLUDES;

private boolean forceScanExternals = false;

@GuardedBy("this")
private transient String uuid;
Expand Down Expand Up @@ -191,6 +195,22 @@ public void setIncludes(String includes) {
this.includes = includes;
}

/**
* Gets the force scan for externals flag
* Workaround for not handling revision numbers of externals.
*
* @return the force scan for externals flag.
*/
@Restricted(NoExternalUse.class)
public boolean getForceScanExternals() {
return forceScanExternals;
}

@DataBoundSetter
public void setForceScanExternals(boolean forceScanExternals) {
this.forceScanExternals = forceScanExternals;
}

/**
* Gets the base SVN URL of the project.
*
Expand Down Expand Up @@ -274,7 +294,11 @@ protected SCMRevision retrieve(@NonNull SCMHead head, @NonNull TaskListener list
String repoPath = SubversionSCM.DescriptorImpl.getRelativePath(repoURL, repository.getRepository());
String path = SVNPathUtil.append(repoPath, head.getName());
SVNRepositoryView.NodeEntry svnEntry = repository.getNode(path, -1);
return new SCMRevisionImpl(head, svnEntry.getRevision());
SCMRevisionImpl revImpl = new SCMRevisionImpl(head, svnEntry.getRevision());
if(forceScanExternals) {
revImpl.setDeterministic(false);
}
return revImpl;
} catch (SVNException e) {
throw new IOException(e);
} finally {
Expand Down Expand Up @@ -309,7 +333,11 @@ protected SCMRevision retrieve(String unparsedRevision, TaskListener listener) t
listener.getLogger().println("Could not find " + path);
return null;
}
return new SCMRevisionImpl(new SCMHead(base), revision == -1 ? resolvedRevision : revision);
SCMRevisionImpl revImpl = new SCMRevisionImpl(new SCMHead(base), revision == -1 ? resolvedRevision : revision);
if(forceScanExternals) {
revImpl.setDeterministic(false);
}
return revImpl;
} catch (SVNException e) {
throw new IOException(e);
} finally {
Expand Down Expand Up @@ -410,7 +438,11 @@ public boolean exists(@NonNull String path) throws IOException {
}, listener)) {
listener.getLogger().println("Met criteria");
SCMHead head = new SCMHead(childPath);
observer.observe(head, new SCMRevisionImpl(head, svnEntry.getRevision()));
SCMRevisionImpl revImpl = new SCMRevisionImpl(head, svnEntry.getRevision());
if(forceScanExternals) {
revImpl.setDeterministic(false);
}
observer.observe(head, revImpl);
if (!observer.isObserving()) {
return;
}
Expand Down Expand Up @@ -702,15 +734,30 @@ public static class SCMRevisionImpl extends SCMRevision {
* The subversion revision.
*/
private long revision;

/**
* Whether or not the revision number is deterministic.
* Workaround for not handling revision numbers of externals.
*/
private boolean deterministic;

public SCMRevisionImpl(SCMHead head, long revision) {
super(head);
this.revision = revision;
deterministic = true;
}

public long getRevision() {
return revision;
}

public void setDeterministic(boolean deterministic) {
this.deterministic = deterministic;
}

public boolean isDeterministic() {
return deterministic;
}

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@
<f:entry title="${%Exclude branches}" field="excludes">
<f:textbox default="${descriptor.DEFAULT_EXCLUDES}"/>
</f:entry>
<f:entry title="${%Force scanning for updates in externals}" field="forceScanExternals">
<f:checkbox/>
</f:entry>
</j:jelly>