mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 19:45:51 +01:00
merge with branch 1.x
This commit is contained in:
@@ -50,12 +50,14 @@ import sonia.scm.repository.spi.GitRepositoryServiceProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import sonia.scm.store.ConfigurationStoreFactory;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.schedule.Scheduler;
|
||||
import sonia.scm.schedule.Task;
|
||||
import sonia.scm.store.ConfigurationStoreFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -195,21 +197,17 @@ public class GitRepositoryHandler
|
||||
protected void create(Repository repository, File directory)
|
||||
throws RepositoryException, IOException
|
||||
{
|
||||
org.eclipse.jgit.lib.Repository gitRepository = null;
|
||||
|
||||
try
|
||||
{
|
||||
gitRepository = new FileRepositoryBuilder().setGitDir(
|
||||
directory).readEnvironment().findGitDir().build();
|
||||
try (org.eclipse.jgit.lib.Repository gitRepository = build(directory)) {
|
||||
gitRepository.create(true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gitRepository != null)
|
||||
{
|
||||
gitRepository.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private org.eclipse.jgit.lib.Repository build(File directory) throws IOException {
|
||||
return new FileRepositoryBuilder()
|
||||
.setGitDir(directory)
|
||||
.readEnvironment()
|
||||
.findGitDir()
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -271,7 +271,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
walk.markStart(commit);
|
||||
result = Util.getFirst(walk);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.error("could not parse commit for file", ex);
|
||||
}
|
||||
@@ -417,12 +417,9 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
revision);
|
||||
}
|
||||
|
||||
Map<String, SubRepository> subRepositories = null;
|
||||
ByteArrayOutputStream baos = null;
|
||||
|
||||
try
|
||||
Map<String, SubRepository> subRepositories;
|
||||
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() )
|
||||
{
|
||||
baos = new ByteArrayOutputStream();
|
||||
new GitCatCommand(context, repository).getContent(repo, revision,
|
||||
PATH_MODULES, baos);
|
||||
subRepositories = GitSubModuleParser.parse(baos.toString());
|
||||
@@ -431,8 +428,6 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
{
|
||||
logger.trace("could not find .gitmodules", ex);
|
||||
subRepositories = Collections.EMPTY_MAP;
|
||||
} finally {
|
||||
IOUtil.close(baos);
|
||||
}
|
||||
|
||||
return subRepositories;
|
||||
@@ -461,8 +456,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final Map<ObjectId, Map<String, SubRepository>> subrepositoryCache =
|
||||
Maps.newHashMap();
|
||||
|
||||
/** sub repository cache */
|
||||
private final Map<ObjectId, Map<String, SubRepository>> subrepositoryCache = Maps.newHashMap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user