mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
use jgit java7 support, to improve git performance
This commit is contained in:
@@ -38,6 +38,12 @@
|
|||||||
<version>${jgit.version}</version>
|
<version>${jgit.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>sonia.jgit</groupId>
|
||||||
|
<artifactId>org.eclipse.jgit.java7</artifactId>
|
||||||
|
<version>${jgit.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-lang</groupId>
|
<groupId>commons-lang</groupId>
|
||||||
<artifactId>commons-lang</artifactId>
|
<artifactId>commons-lang</artifactId>
|
||||||
|
|||||||
@@ -198,8 +198,6 @@ public final class GitUtil
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*
|
*
|
||||||
* @throws GitAPIException
|
|
||||||
*
|
|
||||||
* @throws RepositoryException
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public static FetchResult fetch(Git git, File directory,
|
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);
|
logger.warn("error occured during resolve of branch id", ex);
|
||||||
}
|
}
|
||||||
@@ -582,7 +580,7 @@ public final class GitUtil
|
|||||||
String revision)
|
String revision)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
ObjectId revId = null;
|
ObjectId revId;
|
||||||
|
|
||||||
if (Util.isNotEmpty(revision))
|
if (Util.isNotEmpty(revision))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,10 +51,8 @@ public class AbstractGitCommand
|
|||||||
* Constructs ...
|
* Constructs ...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param context
|
* @param context
|
||||||
* @param repository
|
* @param repository
|
||||||
* @param repositoryDirectory
|
|
||||||
*/
|
*/
|
||||||
protected AbstractGitCommand(GitContext context,
|
protected AbstractGitCommand(GitContext context,
|
||||||
sonia.scm.repository.Repository repository)
|
sonia.scm.repository.Repository repository)
|
||||||
|
|||||||
@@ -80,10 +80,7 @@ public class GitContext implements Closeable
|
|||||||
@Override
|
@Override
|
||||||
public void close()
|
public void close()
|
||||||
{
|
{
|
||||||
if (logger.isTraceEnabled())
|
logger.trace("close git repository {}", directory);
|
||||||
{
|
|
||||||
logger.trace("close git repository {}", directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
GitUtil.close(repository);
|
GitUtil.close(repository);
|
||||||
repository = null;
|
repository = null;
|
||||||
@@ -101,10 +98,7 @@ public class GitContext implements Closeable
|
|||||||
{
|
{
|
||||||
if (repository == null)
|
if (repository == null)
|
||||||
{
|
{
|
||||||
if (logger.isTraceEnabled())
|
logger.trace("open git repository {}", directory);
|
||||||
{
|
|
||||||
logger.trace("open git repository {}", directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
repository = GitUtil.open(directory);
|
repository = GitUtil.open(directory);
|
||||||
}
|
}
|
||||||
@@ -115,7 +109,7 @@ public class GitContext implements Closeable
|
|||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private File directory;
|
private final File directory;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private org.eclipse.jgit.lib.Repository repository;
|
private org.eclipse.jgit.lib.Repository repository;
|
||||||
|
|||||||
@@ -30,11 +30,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.repository;
|
package sonia.scm.repository;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- 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.Test;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.*;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@@ -81,6 +91,25 @@ public class GitUtilTest
|
|||||||
GitUtil.checkBranchName(repo, GitUtil.REF_HEAD_PREFIX.concat("develop"));
|
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
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -98,4 +127,10 @@ public class GitUtilTest
|
|||||||
|
|
||||||
return repo;
|
return repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
@Rule
|
||||||
|
public TemporaryFolder temp = new TemporaryFolder();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user