Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<revision>4.11.5</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<jenkins.version>2.303.3</jenkins.version>
<jenkins.version>2.319.3</jenkins.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update

<artifactId>bom-2.303.x</artifactId>
accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok i updated it, I hope correctly

<no-test-jar>false</no-test-jar>
<useBeta>true</useBeta>
<linkXRef>false</linkXRef>
Expand Down Expand Up @@ -102,6 +102,7 @@
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<version>625.va_c59c48ce36f</version> <!-- TODO: https://github.com/jenkinsci/scm-api-plugin/pull/160 -->
<artifactId>scm-api</artifactId>
</dependency>
<dependency>
Expand Down Expand Up @@ -191,6 +192,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>625.va_c59c48ce36f</version> <!-- TODO: https://github.com/jenkinsci/scm-api-plugin/pull/160 -->
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -255,12 +257,20 @@
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
<repository> <!-- TODO FOR DRAFT -->
<id>incrementals.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/incrementals/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
<pluginRepository><!-- TODO FOR DRAFT -->
<id>incrementals.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/incrementals/</url>
</pluginRepository>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<pluginRepository><!-- TODO FOR DRAFT -->
<id>incrementals.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/incrementals/</url>
</pluginRepository>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must say that I wasnt able to compile it locally without these temporary .pom changes, but I assume they will be removed before it will be merged

</pluginRepositories>

<build>
Expand Down
27 changes: 21 additions & 6 deletions src/main/java/jenkins/plugins/git/GitSCMFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import hudson.EnvVars;
import hudson.Extension;
import hudson.model.Item;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.plugins.git.BranchSpec;
import hudson.plugins.git.GitException;
Expand Down Expand Up @@ -284,14 +285,16 @@ public boolean supportsDescriptor(SCMSourceDescriptor descriptor) {
}

@Override
public SCMFileSystem build(@NonNull Item owner, @NonNull SCM scm, @CheckForNull SCMRevision rev)
public SCMFileSystem build(@NonNull Item owner, @NonNull SCM scm, @CheckForNull SCMRevision rev,
@CheckForNull Run<?,?> _build)
throws IOException, InterruptedException {
if (rev != null && !(rev instanceof AbstractGitSCMSource.SCMRevisionImpl)) {
return null;
}
if (!(scm instanceof GitSCM)) {
return null; // Spotbugs warns about unchecked cast without this check
}

GitSCM gitSCM = (GitSCM) scm;
UserRemoteConfig config = gitSCM.getUserRemoteConfigs().get(0);
BranchSpec branchSpec = gitSCM.getBranches().get(0);
Expand All @@ -301,6 +304,13 @@ public SCMFileSystem build(@NonNull Item owner, @NonNull SCM scm, @CheckForNull
listener.getLogger().println("Git remote url is null");
return null;
}

EnvVars env = null;
if (_build != null)
{
env = _build.getEnvironment(listener);
}

String cacheEntry = AbstractGitSCMSource.getCacheEntry(remote);
Lock cacheLock = AbstractGitSCMSource.getCacheLock(cacheEntry);
cacheLock.lock();
Expand Down Expand Up @@ -353,12 +363,17 @@ public SCMFileSystem build(@NonNull Item owner, @NonNull SCM scm, @CheckForNull
if (rev != null) {
headName = rev.getHead().getName();
} else {
if (branchSpec.getName().startsWith(prefix)){
headName = branchSpec.getName().substring(prefix.length());
} else if (branchSpec.getName().startsWith("*/")) {
headName = branchSpec.getName().substring(2);
String branchSpecExpandedName = branchSpec.getName();
if (env != null) {
branchSpecExpandedName = env.expand(branchSpecExpandedName);
}

if (branchSpecExpandedName.startsWith(prefix)){
headName = branchSpecExpandedName.substring(prefix.length());
} else if (branchSpecExpandedName.startsWith("*/")) {
headName = branchSpecExpandedName.substring(2);
} else {
headName = branchSpec.getName();
headName = branchSpecExpandedName;
}
}
client.fetch_().prune(true).from(remoteURI, Arrays
Expand Down