mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 14:05:44 +01:00
use jgit java7 support, to improve git performance
This commit is contained in:
@@ -198,8 +198,6 @@ public final class GitUtil
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws GitAPIException
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
public static FetchResult fetch(Git git, File directory,
|
||||
@@ -376,7 +374,7 @@ public final class GitUtil
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.warn("error occured during resolve of branch id", ex);
|
||||
}
|
||||
@@ -582,7 +580,7 @@ public final class GitUtil
|
||||
String revision)
|
||||
throws IOException
|
||||
{
|
||||
ObjectId revId = null;
|
||||
ObjectId revId;
|
||||
|
||||
if (Util.isNotEmpty(revision))
|
||||
{
|
||||
|
||||
@@ -51,10 +51,8 @@ public class AbstractGitCommand
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param context
|
||||
* @param repository
|
||||
* @param repositoryDirectory
|
||||
*/
|
||||
protected AbstractGitCommand(GitContext context,
|
||||
sonia.scm.repository.Repository repository)
|
||||
|
||||
@@ -80,10 +80,7 @@ public class GitContext implements Closeable
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("close git repository {}", directory);
|
||||
}
|
||||
logger.trace("close git repository {}", directory);
|
||||
|
||||
GitUtil.close(repository);
|
||||
repository = null;
|
||||
@@ -101,10 +98,7 @@ public class GitContext implements Closeable
|
||||
{
|
||||
if (repository == null)
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("open git repository {}", directory);
|
||||
}
|
||||
logger.trace("open git repository {}", directory);
|
||||
|
||||
repository = GitUtil.open(directory);
|
||||
}
|
||||
@@ -115,7 +109,7 @@ public class GitContext implements Closeable
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private File directory;
|
||||
private final File directory;
|
||||
|
||||
/** Field description */
|
||||
private org.eclipse.jgit.lib.Repository repository;
|
||||
|
||||
@@ -30,11 +30,21 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@@ -81,6 +91,25 @@ public class GitUtilTest
|
||||
GitUtil.checkBranchName(repo, GitUtil.REF_HEAD_PREFIX.concat("develop"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws GitAPIException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test
|
||||
public void testOpenJava7() throws GitAPIException, IOException
|
||||
{
|
||||
File dir = temp.newFolder();
|
||||
|
||||
Git.init().setDirectory(dir).setBare(true).call();
|
||||
|
||||
org.eclipse.jgit.lib.Repository repo = GitUtil.open(dir);
|
||||
|
||||
assertThat(repo.getFS().getClass().getName(), containsString("Java7"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -98,4 +127,10 @@ public class GitUtilTest
|
||||
|
||||
return repo;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@Rule
|
||||
public TemporaryFolder temp = new TemporaryFolder();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user