Skip to content

Commit

Permalink
Merge pull request #365 from cathychan/multi-parent-and-fallback
Browse files Browse the repository at this point in the history
Clean out local repo before checking out from a different URL
  • Loading branch information
imonteroperez authored May 10, 2022
2 parents 14dd216 + e5c5804 commit f1cc529
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import hudson.model.UpdateSite;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -15,6 +16,7 @@
import org.apache.maven.scm.repository.ScmRepository;
import org.apache.maven.scm.repository.ScmRepositoryException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.util.FileUtils;
import org.jenkins.tools.test.PluginCompatTester;
import org.jenkins.tools.test.SCMManagerFactory;
import org.jenkins.tools.test.model.PluginCompatTesterConfig;
Expand Down Expand Up @@ -80,7 +82,7 @@ public Map<String, Object> action(Map<String, Object> moreInfo) throws Exception
}

private void cloneFromSCM(UpdateSite.Plugin currentPlugin, File parentPath, String scmTag, String url, String fallbackGitHubOrganization)
throws ComponentLookupException, ScmRepositoryException, NoSuchScmProviderException, ScmException {
throws ComponentLookupException, ScmRepositoryException, NoSuchScmProviderException, ScmException, IOException {

List<String> connectionURLs = new ArrayList<String>();
connectionURLs.add(url);
Expand All @@ -97,6 +99,9 @@ private void cloneFromSCM(UpdateSite.Plugin currentPlugin, File parentPath, Stri
connectionURL = connectionURL.replace("git://", "https://"); // See: https://github.blog/2021-09-01-improving-git-protocol-security-github/
}
System.out.println("Checking out from SCM connection URL: " + connectionURL + " (" + getParentProjectName() + "-" + currentPlugin.version + ") at tag " + scmTag);
if (parentPath.isDirectory()) {
FileUtils.deleteDirectory(parentPath);
}
repository = scmManager.makeScmRepository(connectionURL);
CheckOutScmResult result = scmManager.checkOut(repository, new ScmFileSet(parentPath), new ScmTag(scmTag));
if(result.isSuccess()){
Expand Down

0 comments on commit f1cc529

Please sign in to comment.