mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-06 13:35:44 +01:00
use newer repository client api
This commit is contained in:
@@ -82,35 +82,22 @@ public class GitCommitCommand implements CommitCommand
|
||||
@Override
|
||||
public Changeset commit(CommitRequest request) throws IOException
|
||||
{
|
||||
Changeset changeset = null;
|
||||
GitChangesetConverter converter = null;
|
||||
|
||||
try
|
||||
try (GitChangesetConverter converter = new GitChangesetConverter(git.getRepository()))
|
||||
{
|
||||
RevCommit commit = git.commit().setAuthor(
|
||||
request.getAuthor().getName(),
|
||||
request.getAuthor().getMail()).setMessage(
|
||||
request.getMessage()).call();
|
||||
|
||||
converter = new GitChangesetConverter(git.getRepository());
|
||||
|
||||
changeset = converter.createChangeset(commit);
|
||||
return converter.createChangeset(commit);
|
||||
} catch (GitAPIException ex) {
|
||||
throw new RepositoryClientException("could not commit changes to repository", ex);
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new RepositoryClientException(
|
||||
"could not commit changes to repository", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Closeables.closeQuietly(converter);
|
||||
}
|
||||
|
||||
return changeset;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private Git git;
|
||||
private final Git git;
|
||||
}
|
||||
|
||||
@@ -105,13 +105,18 @@ public class GitRepositoryClientFactoryProvider
|
||||
{
|
||||
Git git = null;
|
||||
|
||||
CredentialsProvider credentialsProvider =
|
||||
new UsernamePasswordCredentialsProvider(username, password);
|
||||
CredentialsProvider credentialsProvider = null;
|
||||
if ( username != null && password != null ) {
|
||||
credentialsProvider = new UsernamePasswordCredentialsProvider(username, password);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
git = Git.cloneRepository().setURI(url).setDirectory(
|
||||
workingCopy).setCredentialsProvider(credentialsProvider).call();
|
||||
git = Git.cloneRepository()
|
||||
.setURI(url)
|
||||
.setDirectory(workingCopy)
|
||||
.setCredentialsProvider(credentialsProvider)
|
||||
.call();
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ package sonia.scm.repository.client.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.transport.CredentialsProvider;
|
||||
@@ -188,6 +189,11 @@ public class GitRepositoryClientProvider extends RepositoryClientProvider
|
||||
return new GitTagCommand(git);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorkingCopy() {
|
||||
return git.getRepository().getDirectory();
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
Reference in New Issue
Block a user