merge with branch 1.x

This commit is contained in:
Sebastian Sdorra
2017-01-14 13:25:25 +01:00
22 changed files with 260 additions and 377 deletions

View File

@@ -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();
}
/**

View File

@@ -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();
}