mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
Update jgit to v5.11.1.202105131744-r-scm1 (#1661)
Update jgit to v5.11.1.202105131744-r-scm1 Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
@@ -27,7 +27,7 @@ plugins {
|
||||
id 'org.scm-manager.smp' version '0.7.5'
|
||||
}
|
||||
|
||||
def jgitVersion = '5.10.0.202012080955-r-scm2'
|
||||
def jgitVersion = '5.11.1.202105131744-r-scm1'
|
||||
|
||||
dependencies {
|
||||
// required by scm-it
|
||||
|
||||
@@ -26,6 +26,8 @@ package sonia.scm.repository;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
@@ -39,6 +41,8 @@ import javax.xml.bind.annotation.XmlTransient;
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class GitConfig extends RepositoryConfig {
|
||||
|
||||
private static final String FALLBACK_BRANCH = "main";
|
||||
|
||||
@SuppressWarnings("WeakerAccess") // This might be needed for permission checking
|
||||
public static final String PERMISSION = "git";
|
||||
|
||||
@@ -49,7 +53,7 @@ public class GitConfig extends RepositoryConfig {
|
||||
private boolean nonFastForwardDisallowed;
|
||||
|
||||
@XmlElement(name = "default-branch")
|
||||
private String defaultBranch = "main";
|
||||
private String defaultBranch = FALLBACK_BRANCH;
|
||||
|
||||
public String getGcExpression() {
|
||||
return gcExpression;
|
||||
@@ -68,6 +72,9 @@ public class GitConfig extends RepositoryConfig {
|
||||
}
|
||||
|
||||
public String getDefaultBranch() {
|
||||
if (Strings.isNullOrEmpty(defaultBranch)) {
|
||||
return FALLBACK_BRANCH;
|
||||
}
|
||||
return defaultBranch;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ package sonia.scm.repository.spi;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.api.errors.TransportException;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
@@ -75,6 +76,13 @@ class GitWorkingCopyInitializer {
|
||||
}
|
||||
|
||||
return new ParentAndClone<>(null, clone, target);
|
||||
} catch (TransportException e) {
|
||||
String message = e.getMessage();
|
||||
if (initialBranch != null && message.contains(initialBranch) && message.contains("not found")) {
|
||||
throw notFound(entity("Branch", initialBranch).in(context.getRepository()));
|
||||
} else {
|
||||
throw new InternalRepositoryException(context.getRepository(), "could not clone working copy of repository", e);
|
||||
}
|
||||
} catch (GitAPIException | IOException e) {
|
||||
throw new InternalRepositoryException(context.getRepository(), "could not clone working copy of repository", e);
|
||||
} finally {
|
||||
|
||||
@@ -60,14 +60,14 @@ public class GitModifyCommand_withEmptyRepositoryTest extends GitModifyCommandTe
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateCommitOnMasterByDefault() throws IOException, GitAPIException {
|
||||
public void shouldCreateCommitOnMainByDefault() throws IOException, GitAPIException {
|
||||
createContext().getGlobalConfig().setDefaultBranch("");
|
||||
|
||||
executeModifyCommand();
|
||||
|
||||
try (Git git = new Git(createContext().open())) {
|
||||
List<Ref> branches = git.branchList().call();
|
||||
assertThat(branches).extracting("name").containsExactly("refs/heads/master");
|
||||
assertThat(branches).extracting("name").containsExactly("refs/heads/main");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user