update jgit to 3.0.0.201306101825-r

This commit is contained in:
Sebastian Sdorra
2013-07-08 14:54:44 +02:00
parent fdac4ff01f
commit d2777df1d4
4 changed files with 27 additions and 30 deletions

View File

@@ -430,7 +430,7 @@
<shiro.version>1.2.2</shiro.version> <shiro.version>1.2.2</shiro.version>
<!-- repostitory libraries --> <!-- repostitory libraries -->
<jgit.version>2.3.1.201302201838-r</jgit.version> <jgit.version>3.0.0.201306101825-r</jgit.version>
<svnkit.version>1.7.9-scm2</svnkit.version> <svnkit.version>1.7.9-scm2</svnkit.version>
<!-- build properties --> <!-- build properties -->

View File

@@ -38,7 +38,6 @@ package sonia.scm.repository;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import sonia.scm.Type; import sonia.scm.Type;
@@ -259,19 +258,19 @@ public class GitRepositoryHandler
protected void create(Repository repository, File directory) protected void create(Repository repository, File directory)
throws RepositoryException, IOException throws RepositoryException, IOException
{ {
FileRepository fr = null; org.eclipse.jgit.lib.Repository gitRepository = null;
try try
{ {
fr = new FileRepositoryBuilder().setGitDir( gitRepository = new FileRepositoryBuilder().setGitDir(
directory).readEnvironment().findGitDir().build(); directory).readEnvironment().findGitDir().build();
fr.create(true); gitRepository.create(true);
} }
finally finally
{ {
if (fr != null) if (gitRepository != null)
{ {
fr.close(); gitRepository.close();
} }
} }
} }

View File

@@ -30,13 +30,14 @@
*/ */
package sonia.scm.repository.spi; package sonia.scm.repository.spi;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import org.eclipse.jgit.storage.file.FileRepository; import org.eclipse.jgit.internal.storage.file.FileRepository;
import sonia.scm.repository.GitRepositoryHandler; import sonia.scm.repository.GitRepositoryHandler;
import sonia.scm.repository.GitUtil; import sonia.scm.repository.GitUtil;

View File

@@ -46,6 +46,7 @@ import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.NoRemoteRepositoryException; import org.eclipse.jgit.errors.NoRemoteRepositoryException;
import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.errors.TransportException;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefComparator; import org.eclipse.jgit.lib.RefComparator;
@@ -53,7 +54,6 @@ import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.TextProgressMonitor; import org.eclipse.jgit.lib.TextProgressMonitor;
import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.FetchResult; import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.PushResult; import org.eclipse.jgit.transport.PushResult;
@@ -100,8 +100,8 @@ public class GitRepositoryClient extends AbstractRepositoryClient
* @throws URISyntaxException * @throws URISyntaxException
*/ */
GitRepositoryClient(File localRepository, String remoteRepository, GitRepositoryClient(File localRepository, String remoteRepository,
String username, String password) String username, String password)
throws URISyntaxException, IOException throws URISyntaxException, IOException
{ {
super(localRepository, remoteRepository); super(localRepository, remoteRepository);
uri = new URIish(remoteRepository); uri = new URIish(remoteRepository);
@@ -111,11 +111,11 @@ public class GitRepositoryClient extends AbstractRepositoryClient
uri.setUser(username); uri.setUser(username);
uri.setPass(password); uri.setPass(password);
credentialsProvider = new UsernamePasswordCredentialsProvider(username, credentialsProvider = new UsernamePasswordCredentialsProvider(username,
password); password);
} }
this.repository = new FileRepository(new File(localRepository, this.repository = new FileRepository(new File(localRepository,
Constants.DOT_GIT)); Constants.DOT_GIT));
} }
//~--- methods -------------------------------------------------------------- //~--- methods --------------------------------------------------------------
@@ -131,7 +131,7 @@ public class GitRepositoryClient extends AbstractRepositoryClient
*/ */
@Override @Override
public void add(String file, String... others) public void add(String file, String... others)
throws RepositoryClientException throws RepositoryClientException
{ {
AddCommand cmd = new Git(repository).add(); AddCommand cmd = new Git(repository).add();
@@ -172,7 +172,7 @@ public class GitRepositoryClient extends AbstractRepositoryClient
case REJECTED : case REJECTED :
case REJECTED_CURRENT_BRANCH : case REJECTED_CURRENT_BRANCH :
throw new RepositoryClientException("could not checkout, status " throw new RepositoryClientException("could not checkout, status "
+ ru.getResult().name()); + ru.getResult().name());
} }
} }
@@ -253,9 +253,8 @@ public class GitRepositoryClient extends AbstractRepositoryClient
case REJECTED_REMOTE_CHANGED : case REJECTED_REMOTE_CHANGED :
case REJECTED_OTHER_REASON : case REJECTED_OTHER_REASON :
throw new RepositoryClientException( throw new RepositoryClientException(
"could not update ref ".concat( "could not update ref ".concat(refUpdate.getSrcRef()).concat(
refUpdate.getSrcRef()).concat( " status ".concat(refUpdate.getStatus().toString())));
" status ".concat(refUpdate.getStatus().toString())));
} }
} }
} }
@@ -288,7 +287,7 @@ public class GitRepositoryClient extends AbstractRepositoryClient
{ {
repository.create(false); repository.create(false);
addRemote("origin", new URIish(remoteRepository), "master", null, true, addRemote("origin", new URIish(remoteRepository), "master", null, true,
null); null);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -311,10 +310,9 @@ public class GitRepositoryClient extends AbstractRepositoryClient
* @throws URISyntaxException * @throws URISyntaxException
*/ */
private void addRemote(final String remoteName, final URIish uri, private void addRemote(final String remoteName, final URIish uri,
final String branchName, final String tagName, final String branchName, final String tagName, final boolean allSelected,
final boolean allSelected, final Collection<Ref> selectedBranches)
final Collection<Ref> selectedBranches) throws URISyntaxException, IOException
throws URISyntaxException, IOException
{ {
// add remote configuration // add remote configuration
@@ -349,18 +347,18 @@ public class GitRepositoryClient extends AbstractRepositoryClient
// setup the default remote branch for branchName // setup the default remote branch for branchName
repository.getConfig().setString("branch", branchName, "remote", repository.getConfig().setString("branch", branchName, "remote",
remoteName); remoteName);
if (branchName != null) if (branchName != null)
{ {
repository.getConfig().setString("branch", branchName, "merge", repository.getConfig().setString("branch", branchName, "merge",
Constants.R_HEADS + branchName); Constants.R_HEADS + branchName);
} }
if (tagName != null) if (tagName != null)
{ {
repository.getConfig().setString("branch", branchName, "merge", repository.getConfig().setString("branch", branchName, "merge",
Constants.R_TAGS + branchName); Constants.R_TAGS + branchName);
} }
repository.getConfig().save(); repository.getConfig().save();
@@ -476,8 +474,7 @@ public class GitRepositoryClient extends AbstractRepositoryClient
* @throws MissingObjectException * @throws MissingObjectException
*/ */
private RevCommit parseCommit(Ref branch) private RevCommit parseCommit(Ref branch)
throws MissingObjectException, IncorrectObjectTypeException, throws MissingObjectException, IncorrectObjectTypeException, IOException
IOException
{ {
final RevWalk rw = new RevWalk(repository); final RevWalk rw = new RevWalk(repository);
final RevCommit commit; final RevCommit commit;
@@ -506,8 +503,8 @@ public class GitRepositoryClient extends AbstractRepositoryClient
* @throws URISyntaxException * @throws URISyntaxException
*/ */
private FetchResult runFetch() private FetchResult runFetch()
throws NotSupportedException, URISyntaxException, TransportException, throws NotSupportedException, URISyntaxException, TransportException,
RepositoryClientException RepositoryClientException
{ {
FetchResult r = null; FetchResult r = null;