mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 05:55:44 +01:00
Replace model object exception with generic ones and migrate guice
This commit is contained in:
@@ -38,25 +38,21 @@ package sonia.scm.repository;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.io.FileSystem;
|
||||
import sonia.scm.plugin.Extension;
|
||||
import sonia.scm.repository.spi.GitRepositoryServiceProvider;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
import sonia.scm.schedule.Scheduler;
|
||||
import sonia.scm.schedule.Task;
|
||||
import sonia.scm.store.ConfigurationStoreFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
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;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -185,20 +181,8 @@ public class GitRepositoryHandler
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param directory
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
protected void create(Repository repository, File directory)
|
||||
throws RepositoryException, IOException
|
||||
{
|
||||
protected void create(Repository repository, File directory) throws IOException {
|
||||
try (org.eclipse.jgit.lib.Repository gitRepository = build(directory)) {
|
||||
gitRepository.create(true);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import org.eclipse.jgit.api.FetchCommand;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
@@ -54,23 +53,19 @@ import org.eclipse.jgit.transport.FetchResult;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.util.HttpUtil;
|
||||
import sonia.scm.util.Util;
|
||||
import sonia.scm.web.GitUserAgentProvider;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import sonia.scm.web.GitUserAgentProvider;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -192,22 +187,7 @@ public final class GitUtil
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param git
|
||||
* @param directory
|
||||
* @param remoteRepository
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
public static FetchResult fetch(Git git, File directory,
|
||||
Repository remoteRepository)
|
||||
throws RepositoryException
|
||||
{
|
||||
public static FetchResult fetch(Git git, File directory, Repository remoteRepository) {
|
||||
try
|
||||
{
|
||||
FetchCommand fetch = git.fetch();
|
||||
@@ -220,7 +200,7 @@ public final class GitUtil
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new RepositoryException("could not fetch", ex);
|
||||
throw new InternalRepositoryException("could not fetch", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +274,7 @@ public final class GitUtil
|
||||
{
|
||||
if (walk != null)
|
||||
{
|
||||
walk.close();;
|
||||
walk.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,28 +36,25 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.Closeables;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.GitChangesetConverter;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -117,21 +114,7 @@ public abstract class AbstractGitIncomingOutgoingCommand
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
protected ChangesetPagingResult getIncomingOrOutgoingChangesets(
|
||||
PagedRemoteCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
protected ChangesetPagingResult getIncomingOrOutgoingChangesets(PagedRemoteCommandRequest request) throws IOException {
|
||||
Repository remoteRepository = request.getRemoteRepository();
|
||||
|
||||
Git git = Git.wrap(open());
|
||||
@@ -141,8 +124,7 @@ public abstract class AbstractGitIncomingOutgoingCommand
|
||||
ObjectId localId = getDefaultBranch(git.getRepository());
|
||||
ObjectId remoteId = null;
|
||||
|
||||
Ref remoteBranch = getRemoteBranch(git.getRepository(), localId,
|
||||
remoteRepository);
|
||||
Ref remoteBranch = getRemoteBranch(git.getRepository(), localId, remoteRepository);
|
||||
|
||||
if (remoteBranch != null)
|
||||
{
|
||||
@@ -178,7 +160,7 @@ public abstract class AbstractGitIncomingOutgoingCommand
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new RepositoryException("could not execute incoming command", ex);
|
||||
throw new InternalRepositoryException("could not execute incoming command", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -191,23 +173,7 @@ public abstract class AbstractGitIncomingOutgoingCommand
|
||||
return new ChangesetPagingResult(changesets.size(), changesets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param local
|
||||
* @param remoteRepository
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
private Ref getRemoteBranch(org.eclipse.jgit.lib.Repository repository,
|
||||
ObjectId local, Repository remoteRepository)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
private Ref getRemoteBranch(org.eclipse.jgit.lib.Repository repository, ObjectId local, Repository remoteRepository) throws IOException {
|
||||
Ref ref = null;
|
||||
|
||||
if (local != null)
|
||||
@@ -236,7 +202,7 @@ public abstract class AbstractGitIncomingOutgoingCommand
|
||||
{
|
||||
if (ref != null)
|
||||
{
|
||||
throw new RepositoryException("could not find remote branch");
|
||||
throw new InternalRepositoryException("could not find remote branch");
|
||||
}
|
||||
|
||||
ref = e.getValue();
|
||||
|
||||
@@ -37,28 +37,23 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.transport.PushResult;
|
||||
import org.eclipse.jgit.transport.RemoteRefUpdate;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -94,20 +89,7 @@ public abstract class AbstractGitPushOrPullCommand extends AbstractGitCommand
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
* @param source
|
||||
* @param remoteUrl
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
protected long push(Repository source, String remoteUrl)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
protected long push(Repository source, String remoteUrl) {
|
||||
Git git = Git.wrap(source);
|
||||
org.eclipse.jgit.api.PushCommand push = git.push();
|
||||
|
||||
@@ -132,7 +114,7 @@ public abstract class AbstractGitPushOrPullCommand extends AbstractGitCommand
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new RepositoryException("could not execute push/pull command", ex);
|
||||
throw new InternalRepositoryException("could not execute push/pull command", ex);
|
||||
}
|
||||
|
||||
return counter;
|
||||
|
||||
@@ -37,30 +37,26 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.BlameLine;
|
||||
import sonia.scm.repository.BlameResult;
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
import sonia.scm.repository.Person;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -76,15 +72,6 @@ public class GitBlameCommand extends AbstractGitCommand implements BlameCommand
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param context
|
||||
* @param repository
|
||||
* @param repositoryDirectory
|
||||
*/
|
||||
public GitBlameCommand(GitContext context, Repository repository)
|
||||
{
|
||||
super(context, repository);
|
||||
@@ -92,20 +79,9 @@ public class GitBlameCommand extends AbstractGitCommand implements BlameCommand
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public BlameResult getBlameResult(BlameCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
throws IOException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -132,7 +108,7 @@ public class GitBlameCommand extends AbstractGitCommand implements BlameCommand
|
||||
|
||||
if (gitBlameResult == null)
|
||||
{
|
||||
throw new RepositoryException(
|
||||
throw new InternalRepositoryException(
|
||||
"could not create blame result for path ".concat(
|
||||
request.getPath()));
|
||||
}
|
||||
@@ -174,7 +150,7 @@ public class GitBlameCommand extends AbstractGitCommand implements BlameCommand
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new RepositoryException("could not create blame view", ex);
|
||||
throw new InternalRepositoryException("could not create blame view", ex);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -36,22 +36,19 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
|
||||
import sonia.scm.repository.Branch;
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -74,18 +71,8 @@ public class GitBranchesCommand extends AbstractGitCommand
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public List<Branch> getBranches() throws RepositoryException, IOException
|
||||
{
|
||||
public List<Branch> getBranches() throws IOException {
|
||||
List<Branch> branches = null;
|
||||
|
||||
Git git = new Git(open());
|
||||
@@ -115,7 +102,7 @@ public class GitBranchesCommand extends AbstractGitCommand
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new RepositoryException("could not read branches", ex);
|
||||
throw new InternalRepositoryException("could not read branches", ex);
|
||||
}
|
||||
|
||||
return branches;
|
||||
|
||||
@@ -37,7 +37,6 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@@ -49,29 +48,25 @@ import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
import org.eclipse.jgit.treewalk.filter.AndTreeFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.PathFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.BrowserResult;
|
||||
import sonia.scm.repository.FileObject;
|
||||
import sonia.scm.repository.GitSubModuleParser;
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.PathNotFoundException;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.RevisionNotFoundException;
|
||||
import sonia.scm.repository.SubRepository;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -105,22 +100,10 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public BrowserResult getBrowserResult(BrowseCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
throws IOException, RevisionNotFoundException {
|
||||
logger.debug("try to create browse result for {}", request);
|
||||
|
||||
BrowserResult result;
|
||||
@@ -174,8 +157,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
*/
|
||||
private FileObject createFileObject(org.eclipse.jgit.lib.Repository repo,
|
||||
BrowseCommandRequest request, ObjectId revId, TreeWalk treeWalk)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
throws IOException, RevisionNotFoundException {
|
||||
FileObject file;
|
||||
|
||||
try
|
||||
@@ -283,24 +265,9 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repo
|
||||
* @param request
|
||||
* @param revId
|
||||
* @param path
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
private BrowserResult getResult(org.eclipse.jgit.lib.Repository repo,
|
||||
BrowseCommandRequest request, ObjectId revId)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
throws IOException, RevisionNotFoundException {
|
||||
BrowserResult result = null;
|
||||
RevWalk revWalk = null;
|
||||
TreeWalk treeWalk = null;
|
||||
@@ -393,24 +360,11 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repo
|
||||
* @param revision
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<String,
|
||||
SubRepository> getSubRepositories(org.eclipse.jgit.lib.Repository repo,
|
||||
ObjectId revision)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
throws IOException, RevisionNotFoundException {
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("read submodules of {} at {}", repository.getName(),
|
||||
@@ -435,8 +389,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
|
||||
private SubRepository getSubRepository(org.eclipse.jgit.lib.Repository repo,
|
||||
ObjectId revId, String path)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
throws IOException, RevisionNotFoundException {
|
||||
Map<String, SubRepository> subRepositories = subrepositoryCache.get(revId);
|
||||
|
||||
if (subRepositories == null)
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.PathNotFoundException;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.RevisionNotFoundException;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
@@ -66,7 +65,7 @@ public class GitCatCommand extends AbstractGitCommand implements CatCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCatResult(CatCommandRequest request, OutputStream output) throws IOException, RepositoryException {
|
||||
public void getCatResult(CatCommandRequest request, OutputStream output) throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
logger.debug("try to read content for {}", request);
|
||||
try (ClosableObjectLoaderContainer closableObjectLoaderContainer = getLoader(request)) {
|
||||
closableObjectLoaderContainer.objectLoader.copyTo(output);
|
||||
@@ -74,24 +73,24 @@ public class GitCatCommand extends AbstractGitCommand implements CatCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getCatResultStream(CatCommandRequest request) throws IOException, RepositoryException {
|
||||
public InputStream getCatResultStream(CatCommandRequest request) throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
logger.debug("try to read content for {}", request);
|
||||
return new InputStreamWrapper(getLoader(request));
|
||||
}
|
||||
|
||||
void getContent(org.eclipse.jgit.lib.Repository repo, ObjectId revId, String path, OutputStream output) throws IOException, RepositoryException {
|
||||
void getContent(org.eclipse.jgit.lib.Repository repo, ObjectId revId, String path, OutputStream output) throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
try (ClosableObjectLoaderContainer closableObjectLoaderContainer = getLoader(repo, revId, path)) {
|
||||
closableObjectLoaderContainer.objectLoader.copyTo(output);
|
||||
}
|
||||
}
|
||||
|
||||
private ClosableObjectLoaderContainer getLoader(CatCommandRequest request) throws IOException, RepositoryException {
|
||||
private ClosableObjectLoaderContainer getLoader(CatCommandRequest request) throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
org.eclipse.jgit.lib.Repository repo = open();
|
||||
ObjectId revId = getCommitOrDefault(repo, request.getRevision());
|
||||
return getLoader(repo, revId, request.getPath());
|
||||
}
|
||||
|
||||
private ClosableObjectLoaderContainer getLoader(Repository repo, ObjectId revId, String path) throws IOException, RepositoryException {
|
||||
private ClosableObjectLoaderContainer getLoader(Repository repo, ObjectId revId, String path) throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
TreeWalk treeWalk = new TreeWalk(repo);
|
||||
treeWalk.setRecursive(Util.nonNull(path).contains("/"));
|
||||
|
||||
|
||||
@@ -36,16 +36,14 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import org.eclipse.jgit.api.LogCommand;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -70,22 +68,8 @@ public class GitIncomingCommand extends AbstractGitIncomingOutgoingCommand
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public ChangesetPagingResult getIncomingChangesets(
|
||||
IncomingCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
public ChangesetPagingResult getIncomingChangesets(IncomingCommandRequest request) throws IOException {
|
||||
return getIncomingOrOutgoingChangesets(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
@@ -45,25 +44,22 @@ import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.treewalk.filter.AndTreeFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.PathFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.GitChangesetConverter;
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -165,7 +161,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public ChangesetPagingResult getChangesets(LogCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
throws IOException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -268,7 +264,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new RepositoryException("could not create change log", ex);
|
||||
throw new InternalRepositoryException("could not create change log", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -36,16 +36,14 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import org.eclipse.jgit.api.LogCommand;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -84,7 +82,7 @@ public class GitOutgoingCommand extends AbstractGitIncomingOutgoingCommand
|
||||
@Override
|
||||
public ChangesetPagingResult getOutgoingChangesets(
|
||||
OutgoingCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
throws IOException
|
||||
{
|
||||
return getIncomingOrOutgoingChangesets(request);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@@ -46,23 +45,20 @@ import org.eclipse.jgit.transport.FetchResult;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.eclipse.jgit.transport.TagOpt;
|
||||
import org.eclipse.jgit.transport.TrackingRefUpdate;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.api.PullResponse;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -109,7 +105,7 @@ public class GitPullCommand extends AbstractGitPushOrPullCommand
|
||||
*/
|
||||
@Override
|
||||
public PullResponse pull(PullCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
throws IOException
|
||||
{
|
||||
PullResponse response;
|
||||
Repository sourceRepository = request.getRemoteRepository();
|
||||
@@ -130,21 +126,7 @@ public class GitPullCommand extends AbstractGitPushOrPullCommand
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param git
|
||||
* @param result
|
||||
* @param fetch
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
private PullResponse convert(Git git, FetchResult fetch)
|
||||
throws RepositoryException
|
||||
{
|
||||
private PullResponse convert(Git git, FetchResult fetch) {
|
||||
long counter = 0l;
|
||||
|
||||
for (TrackingRefUpdate tru : fetch.getTrackingRefUpdates())
|
||||
@@ -212,19 +194,8 @@ public class GitPullCommand extends AbstractGitPushOrPullCommand
|
||||
return counter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param sourceRepository
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
private PullResponse pullFromScmRepository(Repository sourceRepository)
|
||||
throws IOException, RepositoryException
|
||||
throws IOException
|
||||
{
|
||||
File sourceDirectory = handler.getDirectory(sourceRepository);
|
||||
|
||||
@@ -256,19 +227,8 @@ public class GitPullCommand extends AbstractGitPushOrPullCommand
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param url
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
private PullResponse pullFromUrl(URL url)
|
||||
throws IOException, RepositoryException
|
||||
throws IOException
|
||||
{
|
||||
logger.debug("pull changes from {} to {}", url, repository.getId());
|
||||
|
||||
@@ -289,7 +249,7 @@ public class GitPullCommand extends AbstractGitPushOrPullCommand
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new RepositoryException("error durring pull", ex);
|
||||
throw new InternalRepositoryException("error durring pull", ex);
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
@@ -37,16 +37,14 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.api.PushResponse;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -91,7 +89,7 @@ public class GitPushCommand extends AbstractGitPushOrPullCommand
|
||||
*/
|
||||
@Override
|
||||
public PushResponse push(PushCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
throws IOException
|
||||
{
|
||||
String remoteUrl = getRemoteUrl(request);
|
||||
|
||||
|
||||
@@ -37,27 +37,23 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.Tag;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -79,17 +75,8 @@ public class GitTagsCommand extends AbstractGitCommand implements TagsCommand
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public List<Tag> getTags() throws IOException, RepositoryException
|
||||
public List<Tag> getTags() throws IOException
|
||||
{
|
||||
List<Tag> tags = null;
|
||||
|
||||
@@ -108,7 +95,7 @@ public class GitTagsCommand extends AbstractGitCommand implements TagsCommand
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new RepositoryException("could not read tags from repository", ex);
|
||||
throw new InternalRepositoryException("could not read tags from repository", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -40,17 +40,14 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.Branch;
|
||||
import sonia.scm.repository.Branches;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.Person;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.api.RepositoryService;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
import sonia.scm.template.Template;
|
||||
@@ -60,16 +57,14 @@ import sonia.scm.util.HttpUtil;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -113,21 +108,9 @@ public class GitRepositoryViewer
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param repository
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
public void handleRequest(HttpServletRequest request,
|
||||
HttpServletResponse response, Repository repository)
|
||||
throws RepositoryException, IOException
|
||||
throws IOException
|
||||
{
|
||||
|
||||
String baseUrl = HttpUtil.getCompleteUrl(request);
|
||||
@@ -171,7 +154,7 @@ public class GitRepositoryViewer
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
private BranchesModel createBranchesModel(Repository repository)
|
||||
throws RepositoryException, IOException
|
||||
throws IOException
|
||||
{
|
||||
BranchesModel model = null;
|
||||
RepositoryService service = null;
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.eclipse.jgit.http.server.GitServlet;
|
||||
import org.eclipse.jgit.lfs.lib.Constants;
|
||||
import org.slf4j.Logger;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.RepositoryProvider;
|
||||
import sonia.scm.repository.RepositoryRequestListenerUtil;
|
||||
import sonia.scm.util.HttpUtil;
|
||||
@@ -214,7 +213,7 @@ public class ScmGitServlet extends GitServlet
|
||||
private void handleBrowserRequest(HttpServletRequest request, HttpServletResponse response, Repository repository) throws ServletException, IOException {
|
||||
try {
|
||||
repositoryViewer.handleRequest(request, response, repository);
|
||||
} catch (RepositoryException | IOException ex) {
|
||||
} catch (IOException ex) {
|
||||
throw new ServletException("could not create repository view", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,17 +35,16 @@ package sonia.scm.repository.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.BlameLine;
|
||||
import sonia.scm.repository.BlameResult;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
import sonia.scm.repository.GitConstants;
|
||||
|
||||
import java.io.IOException;
|
||||
import sonia.scm.repository.GitConstants;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Unit tests for {@link GitBlameCommand}.
|
||||
@@ -59,10 +58,10 @@ public class GitBlameCommandTest extends AbstractGitCommandTestBase
|
||||
* Tests blame command with default branch.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
* @
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultBranch() throws IOException, RepositoryException {
|
||||
public void testDefaultBranch() throws IOException {
|
||||
// without default branch, the repository head should be used
|
||||
BlameCommandRequest request = new BlameCommandRequest();
|
||||
request.setPath("a.txt");
|
||||
@@ -89,7 +88,7 @@ public class GitBlameCommandTest extends AbstractGitCommandTestBase
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetBlameResult() throws IOException, RepositoryException
|
||||
public void testGetBlameResult() throws IOException
|
||||
{
|
||||
BlameCommandRequest request = new BlameCommandRequest();
|
||||
|
||||
@@ -124,7 +123,7 @@ public class GitBlameCommandTest extends AbstractGitCommandTestBase
|
||||
*/
|
||||
@Test
|
||||
public void testGetBlameResultWithRevision()
|
||||
throws IOException, RepositoryException
|
||||
throws IOException
|
||||
{
|
||||
BlameCommandRequest request = new BlameCommandRequest();
|
||||
|
||||
|
||||
@@ -36,19 +36,20 @@ package sonia.scm.repository.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.BrowserResult;
|
||||
import sonia.scm.repository.FileObject;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
import sonia.scm.repository.GitConstants;
|
||||
import sonia.scm.repository.RevisionNotFoundException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
import sonia.scm.repository.GitConstants;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Unit tests for {@link GitBrowseCommand}.
|
||||
@@ -60,12 +61,9 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase
|
||||
|
||||
/**
|
||||
* Test browse command with default branch.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultBranch() throws IOException, RepositoryException {
|
||||
public void testDefaultBranch() throws IOException, RevisionNotFoundException {
|
||||
// without default branch, the repository head should be used
|
||||
BrowserResult result = createCommand().getBrowserResult(new BrowseCommandRequest());
|
||||
assertNotNull(result);
|
||||
@@ -94,16 +92,8 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase
|
||||
assertEquals("c", foList.get(1).getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testBrowse() throws IOException, RepositoryException
|
||||
{
|
||||
public void testBrowse() throws IOException, RevisionNotFoundException {
|
||||
BrowserResult result =
|
||||
createCommand().getBrowserResult(new BrowseCommandRequest());
|
||||
|
||||
@@ -143,16 +133,8 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase
|
||||
assertEquals("c", c.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testBrowseSubDirectory() throws IOException, RepositoryException
|
||||
{
|
||||
public void testBrowseSubDirectory() throws IOException, RevisionNotFoundException {
|
||||
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||
|
||||
request.setPath("c");
|
||||
@@ -198,16 +180,8 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase
|
||||
checkDate(e.getLastModified());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testRecusive() throws IOException, RepositoryException
|
||||
{
|
||||
public void testRecusive() throws IOException, RevisionNotFoundException {
|
||||
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||
|
||||
request.setRecursive(true);
|
||||
|
||||
@@ -35,7 +35,6 @@ package sonia.scm.repository.spi;
|
||||
import org.junit.Test;
|
||||
import sonia.scm.repository.GitConstants;
|
||||
import sonia.scm.repository.PathNotFoundException;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.RevisionNotFoundException;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -54,7 +53,7 @@ import static org.junit.Assert.assertEquals;
|
||||
public class GitCatCommandTest extends AbstractGitCommandTestBase {
|
||||
|
||||
@Test
|
||||
public void testDefaultBranch() throws IOException, RepositoryException {
|
||||
public void testDefaultBranch() throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
// without default branch, the repository head should be used
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
request.setPath("a.txt");
|
||||
@@ -67,7 +66,7 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCat() throws IOException, RepositoryException {
|
||||
public void testCat() throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
|
||||
request.setPath("a.txt");
|
||||
@@ -76,7 +75,7 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleCat() throws IOException, RepositoryException {
|
||||
public void testSimpleCat() throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
|
||||
request.setPath("b.txt");
|
||||
@@ -84,7 +83,7 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = PathNotFoundException.class)
|
||||
public void testUnknownFile() throws IOException, RepositoryException {
|
||||
public void testUnknownFile() throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
|
||||
request.setPath("unknown");
|
||||
@@ -92,7 +91,7 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = RevisionNotFoundException.class)
|
||||
public void testUnknownRevision() throws IOException, RepositoryException {
|
||||
public void testUnknownRevision() throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
|
||||
request.setRevision("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
@@ -101,7 +100,7 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleStream() throws IOException, RepositoryException {
|
||||
public void testSimpleStream() throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
request.setPath("b.txt");
|
||||
|
||||
@@ -114,7 +113,7 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase {
|
||||
catResultStream.close();
|
||||
}
|
||||
|
||||
private String execute(CatCommandRequest request) throws IOException, RepositoryException {
|
||||
private String execute(CatCommandRequest request) throws IOException, PathNotFoundException, RevisionNotFoundException {
|
||||
String content = null;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -36,18 +36,16 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -67,7 +65,7 @@ public class GitIncomingCommandTest
|
||||
*/
|
||||
@Test
|
||||
public void testGetIncomingChangesets()
|
||||
throws IOException, GitAPIException, RepositoryException
|
||||
throws IOException, GitAPIException
|
||||
{
|
||||
write(outgoing, outgoingDirectory, "a.txt", "content of a.txt");
|
||||
|
||||
@@ -101,7 +99,7 @@ public class GitIncomingCommandTest
|
||||
*/
|
||||
@Test
|
||||
public void testGetIncomingChangesetsWithAllreadyPullChangesets()
|
||||
throws IOException, GitAPIException, RepositoryException
|
||||
throws IOException, GitAPIException
|
||||
{
|
||||
write(outgoing, outgoingDirectory, "a.txt", "content of a.txt");
|
||||
|
||||
@@ -138,7 +136,7 @@ public class GitIncomingCommandTest
|
||||
*/
|
||||
@Test
|
||||
public void testGetIncomingChangesetsWithEmptyRepository()
|
||||
throws IOException, RepositoryException
|
||||
throws IOException
|
||||
{
|
||||
GitIncomingCommand cmd = createCommand();
|
||||
IncomingCommandRequest request = new IncomingCommandRequest();
|
||||
@@ -163,7 +161,7 @@ public class GitIncomingCommandTest
|
||||
@Test
|
||||
@Ignore
|
||||
public void testGetIncomingChangesetsWithUnrelatedRepository()
|
||||
throws IOException, RepositoryException, GitAPIException
|
||||
throws IOException, GitAPIException
|
||||
{
|
||||
write(outgoing, outgoingDirectory, "a.txt", "content of a.txt");
|
||||
|
||||
|
||||
@@ -35,22 +35,23 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.GitConstants;
|
||||
import sonia.scm.repository.Modifications;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import sonia.scm.repository.GitConstants;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Unit tests for {@link GitLogCommand}.
|
||||
@@ -65,10 +66,10 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws GitAPIException
|
||||
* @throws RepositoryException
|
||||
* @
|
||||
*/
|
||||
@Test
|
||||
public void testGetDefaultBranch() throws IOException, GitAPIException, RepositoryException {
|
||||
public void testGetDefaultBranch() throws IOException, GitAPIException {
|
||||
// without default branch, the repository head should be used
|
||||
ChangesetPagingResult result = createCommand().getChangesets(new LogCommandRequest());
|
||||
|
||||
@@ -99,7 +100,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAll() throws IOException, RepositoryException
|
||||
public void testGetAll() throws IOException
|
||||
{
|
||||
ChangesetPagingResult result =
|
||||
createCommand().getChangesets(new LogCommandRequest());
|
||||
@@ -117,7 +118,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllByPath() throws IOException, RepositoryException
|
||||
public void testGetAllByPath() throws IOException
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
@@ -140,7 +141,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllWithLimit() throws IOException, RepositoryException
|
||||
public void testGetAllWithLimit() throws IOException
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
@@ -171,7 +172,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllWithPaging() throws IOException, RepositoryException
|
||||
public void testGetAllWithPaging() throws IOException
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
@@ -231,7 +232,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetRange() throws IOException, RepositoryException
|
||||
public void testGetRange() throws IOException
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
|
||||
@@ -37,19 +37,16 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link OutgoingCommand}.
|
||||
*
|
||||
@@ -68,7 +65,7 @@ public class GitOutgoingCommandTest extends AbstractRemoteCommandTestBase
|
||||
*/
|
||||
@Test
|
||||
public void testGetOutgoingChangesets()
|
||||
throws IOException, GitAPIException, RepositoryException
|
||||
throws IOException, GitAPIException
|
||||
{
|
||||
write(outgoing, outgoingDirectory, "a.txt", "content of a.txt");
|
||||
|
||||
@@ -102,7 +99,7 @@ public class GitOutgoingCommandTest extends AbstractRemoteCommandTestBase
|
||||
*/
|
||||
@Test
|
||||
public void testGetOutgoingChangesetsWithAllreadyPushedChanges()
|
||||
throws IOException, GitAPIException, RepositoryException
|
||||
throws IOException, GitAPIException
|
||||
{
|
||||
write(outgoing, outgoingDirectory, "a.txt", "content of a.txt");
|
||||
|
||||
@@ -142,7 +139,7 @@ public class GitOutgoingCommandTest extends AbstractRemoteCommandTestBase
|
||||
*/
|
||||
@Test
|
||||
public void testGetOutgoingChangesetsWithEmptyRepository()
|
||||
throws IOException, RepositoryException
|
||||
throws IOException
|
||||
{
|
||||
GitOutgoingCommand cmd = createCommand();
|
||||
OutgoingCommandRequest request = new OutgoingCommandRequest();
|
||||
|
||||
@@ -37,20 +37,17 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.api.PushResponse;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -68,7 +65,7 @@ public class GitPushCommandTest extends AbstractRemoteCommandTestBase
|
||||
*/
|
||||
@Test
|
||||
public void testPush()
|
||||
throws IOException, GitAPIException, RepositoryException
|
||||
throws IOException, GitAPIException
|
||||
{
|
||||
write(outgoing, outgoingDirectory, "a.txt", "content of a.txt");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user