mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-06 13:35:44 +01:00
Merged 2.0.0-m3 into feature/global_config_v2_endpoint
This commit is contained in:
@@ -39,6 +39,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -46,7 +47,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
*/
|
||||
@XmlRootElement(name = "config")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class GitConfig extends SimpleRepositoryConfig {
|
||||
public class GitConfig extends RepositoryConfig {
|
||||
|
||||
@XmlElement(name = "gc-expression")
|
||||
private String gcExpression;
|
||||
@@ -59,4 +60,11 @@ public class GitConfig extends SimpleRepositoryConfig {
|
||||
public void setGcExpression(String gcExpression) {
|
||||
this.gcExpression = gcExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
@XmlTransient // Only for permission checks, don't serialize to XML
|
||||
public String getId() {
|
||||
// Don't change this without migrating SCM permission configuration!
|
||||
return "git";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
*/
|
||||
package sonia.scm.repository;
|
||||
|
||||
import com.github.legman.Subscribe;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.EagerSingleton;
|
||||
|
||||
@@ -40,24 +40,21 @@ import org.eclipse.jgit.transport.PostReceiveHook;
|
||||
import org.eclipse.jgit.transport.PreReceiveHook;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||
import org.eclipse.jgit.transport.ReceivePack;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.RepositoryHookType;
|
||||
import sonia.scm.repository.RepositoryUtil;
|
||||
import sonia.scm.repository.spi.GitHookContextProvider;
|
||||
import sonia.scm.repository.spi.HookEventFacade;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -131,15 +128,14 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
|
||||
try
|
||||
{
|
||||
Repository repository = rpack.getRepository();
|
||||
String repositoryName = resolveRepositoryName(repository);
|
||||
String id = resolveRepositoryId(repository);
|
||||
|
||||
logger.trace("resolved repository name to {}", repositoryName);
|
||||
logger.trace("resolved repository to id {}", id);
|
||||
|
||||
GitHookContextProvider context = new GitHookContextProvider(rpack,
|
||||
receiveCommands);
|
||||
|
||||
hookEventFacade.handle(GitRepositoryHandler.TYPE_NAME,
|
||||
repositoryName).fireHookEvent(type, context);
|
||||
hookEventFacade.handle(id).fireHookEvent(type, context);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -191,7 +187,7 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private String resolveRepositoryName(Repository repository) throws IOException
|
||||
private String resolveRepositoryId(Repository repository) throws IOException
|
||||
{
|
||||
File directory;
|
||||
|
||||
@@ -204,7 +200,7 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
|
||||
directory = repository.getWorkTree();
|
||||
}
|
||||
|
||||
return RepositoryUtil.getRepositoryName(handler, directory);
|
||||
return RepositoryUtil.getRepositoryId(handler, directory);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
@@ -36,8 +36,8 @@ package sonia.scm.web;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.lib.RepositoryCache;
|
||||
@@ -46,19 +46,17 @@ import org.eclipse.jgit.transport.resolver.RepositoryResolver;
|
||||
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
|
||||
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.GitConfig;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.RepositoryProvider;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -72,17 +70,11 @@ public class GitRepositoryResolver implements RepositoryResolver<HttpServletRequ
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
*/
|
||||
@Inject
|
||||
public GitRepositoryResolver(GitRepositoryHandler handler)
|
||||
public GitRepositoryResolver(GitRepositoryHandler handler, RepositoryProvider repositoryProvider)
|
||||
{
|
||||
this.handler = handler;
|
||||
this.repositoryProvider = repositoryProvider;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
@@ -101,26 +93,27 @@ public class GitRepositoryResolver implements RepositoryResolver<HttpServletRequ
|
||||
* @throws ServiceNotEnabledException
|
||||
*/
|
||||
@Override
|
||||
public Repository open(HttpServletRequest request, String repositoryName)
|
||||
throws RepositoryNotFoundException, ServiceNotAuthorizedException,
|
||||
ServiceNotEnabledException
|
||||
public Repository open(HttpServletRequest request, String repositoryName) throws RepositoryNotFoundException, ServiceNotEnabledException
|
||||
{
|
||||
Repository repository = null;
|
||||
|
||||
try
|
||||
{
|
||||
sonia.scm.repository.Repository repo = repositoryProvider.get();
|
||||
|
||||
Preconditions.checkState(repo != null, "repository to handle not found");
|
||||
Preconditions.checkState(GitRepositoryHandler.TYPE_NAME.equals(repo.getType()), "got a non git repository in GitRepositoryResolver of type " + repo.getType());
|
||||
|
||||
GitConfig config = handler.getConfig();
|
||||
|
||||
if (config.isValid())
|
||||
{
|
||||
File gitdir = findRepository(config.getRepositoryDirectory(), repositoryName);
|
||||
File gitdir = findRepository(config.getRepositoryDirectory(), repo.getId());
|
||||
if (gitdir == null) {
|
||||
throw new RepositoryNotFoundException(repositoryName);
|
||||
}
|
||||
|
||||
|
||||
logger.debug("try to open git repository at {}", gitdir);
|
||||
|
||||
repository = RepositoryCache.open(FileKey.lenient(gitdir, FS.DETECTED), true);
|
||||
return RepositoryCache.open(FileKey.lenient(gitdir, FS.DETECTED), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -136,10 +129,8 @@ public class GitRepositoryResolver implements RepositoryResolver<HttpServletRequ
|
||||
{
|
||||
throw new RepositoryNotFoundException(repositoryName, e);
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
|
||||
@VisibleForTesting
|
||||
File findRepository(File parentDirectory, String repositoryName) {
|
||||
File repositoryDirectory = new File(parentDirectory, repositoryName);
|
||||
@@ -168,6 +159,6 @@ public class GitRepositoryResolver implements RepositoryResolver<HttpServletRequ
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private GitRepositoryHandler handler;
|
||||
private final GitRepositoryHandler handler;
|
||||
private final RepositoryProvider repositoryProvider;
|
||||
}
|
||||
|
||||
@@ -56,9 +56,6 @@ import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
import sonia.scm.template.Template;
|
||||
import sonia.scm.template.TemplateEngine;
|
||||
import sonia.scm.template.TemplateEngineFactory;
|
||||
import sonia.scm.url.RepositoryUrlProvider;
|
||||
import sonia.scm.url.UrlProvider;
|
||||
import sonia.scm.url.UrlProviderFactory;
|
||||
import sonia.scm.util.HttpUtil;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.util.Util;
|
||||
@@ -137,21 +134,14 @@ public class GitRepositoryViewer
|
||||
|
||||
logger.trace("render git repository quick view with base url {}", baseUrl);
|
||||
|
||||
UrlProvider urlProvider = UrlProviderFactory.createUrlProvider(baseUrl,
|
||||
UrlProviderFactory.TYPE_WUI);
|
||||
|
||||
response.setContentType(MIMETYPE_HTML);
|
||||
|
||||
RepositoryUrlProvider rup = urlProvider.getRepositoryUrlProvider();
|
||||
|
||||
TemplateEngine engine = templateEngineFactory.getDefaultEngine();
|
||||
Template template = engine.getTemplate(RESOURCE_GITINDEX);
|
||||
//J-
|
||||
ImmutableMap<String,Object> env = ImmutableMap.of(
|
||||
"repository", repository,
|
||||
"branches", createBranchesModel(repository),
|
||||
"commitViewLink", rup.getChangesetUrl(repository.getId(), 0, 20),
|
||||
"sourceViewLink", rup.getBrowseUrl(repository.getId(), null, null)
|
||||
"branches", createBranchesModel(repository)
|
||||
);
|
||||
//J+
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
package sonia.scm.web.lfs;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.github.legman.Subscribe;
|
||||
import com.google.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -118,23 +118,6 @@
|
||||
</tbody>
|
||||
</table>
|
||||
{{/branches}}
|
||||
|
||||
<h2>Notes</h2>
|
||||
|
||||
<div>
|
||||
<p>
|
||||
This page is only a quick view for git commits.
|
||||
The full commit view is <a href="{{commitViewLink}}">here</a>.
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{commitViewLink}}">Commits</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{sourceViewLink}}">Source</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h2>Git Informations</h2>
|
||||
<ul>
|
||||
@@ -144,4 +127,4 @@
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* <p>
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* <p>
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@@ -24,50 +24,45 @@
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* <p>
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.io.DefaultFileSystem;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import sonia.scm.store.ConfigurationStoreFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import sonia.scm.io.DefaultFileSystem;
|
||||
import sonia.scm.schedule.Scheduler;
|
||||
import sonia.scm.store.ConfigurationStoreFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class GitRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase
|
||||
{
|
||||
public class GitRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
|
||||
|
||||
@Mock
|
||||
private Scheduler scheduler;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param directory
|
||||
*/
|
||||
|
||||
@Mock
|
||||
private ConfigurationStoreFactory factory;
|
||||
|
||||
@Override
|
||||
protected void checkDirectory(File directory)
|
||||
{
|
||||
protected void checkDirectory(File directory) {
|
||||
File head = new File(directory, "HEAD");
|
||||
|
||||
assertTrue(head.exists());
|
||||
@@ -84,21 +79,12 @@ public class GitRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase
|
||||
assertTrue(refs.isDirectory());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param factory
|
||||
* @param directory
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected RepositoryHandler createRepositoryHandler(ConfigurationStoreFactory factory,
|
||||
File directory)
|
||||
{
|
||||
File directory) {
|
||||
GitRepositoryHandler repositoryHandler = new GitRepositoryHandler(factory,
|
||||
new DefaultFileSystem(), scheduler);
|
||||
new DefaultFileSystem(), scheduler);
|
||||
|
||||
repositoryHandler.init(contextProvider);
|
||||
|
||||
@@ -110,4 +96,19 @@ public class GitRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase
|
||||
|
||||
return repositoryHandler;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDirectory() {
|
||||
GitRepositoryHandler repositoryHandler = new GitRepositoryHandler(factory,
|
||||
new DefaultFileSystem(), scheduler);
|
||||
|
||||
GitConfig gitConfig = new GitConfig();
|
||||
gitConfig.setRepositoryDirectory(new File("/path"));
|
||||
repositoryHandler.setConfig(gitConfig);
|
||||
|
||||
Repository repository = new Repository("id", "git", "Space", "Name");
|
||||
|
||||
File path = repositoryHandler.getDirectory(repository);
|
||||
assertEquals("/path/id", path.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,9 @@
|
||||
package sonia.scm.repository;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link GitRepositoryPathMatcher}.
|
||||
@@ -45,18 +47,18 @@ public class GitRepositoryPathMatcherTest {
|
||||
|
||||
@Test
|
||||
public void testIsPathMatching() {
|
||||
assertFalse(pathMatcher.isPathMatching(repository("my-repo"), "my-repoo"));
|
||||
assertFalse(pathMatcher.isPathMatching(repository("my"), "my-repo"));
|
||||
assertFalse(pathMatcher.isPathMatching(repository("my"), "my-repo/with/path"));
|
||||
assertFalse(pathMatcher.isPathMatching(repository("space", "my-repo"), "my-repoo"));
|
||||
assertFalse(pathMatcher.isPathMatching(repository("space", "my"), "my-repo"));
|
||||
assertFalse(pathMatcher.isPathMatching(repository("space", "my"), "my-repo/with/path"));
|
||||
|
||||
assertTrue(pathMatcher.isPathMatching(repository("my-repo"), "my-repo"));
|
||||
assertTrue(pathMatcher.isPathMatching(repository("my-repo"), "my-repo.git"));
|
||||
assertTrue(pathMatcher.isPathMatching(repository("my-repo"), "my-repo/with/path"));
|
||||
assertTrue(pathMatcher.isPathMatching(repository("my-repo"), "my-repo.git/with/path"));
|
||||
assertTrue(pathMatcher.isPathMatching(repository("space", "my-repo"), "my-repo"));
|
||||
assertTrue(pathMatcher.isPathMatching(repository("space", "my-repo"), "my-repo.git"));
|
||||
assertTrue(pathMatcher.isPathMatching(repository("space", "my-repo"), "my-repo/with/path"));
|
||||
assertTrue(pathMatcher.isPathMatching(repository("space", "my-repo"), "my-repo.git/with/path"));
|
||||
}
|
||||
|
||||
private Repository repository(String name) {
|
||||
return new Repository(name, GitRepositoryHandler.TYPE_NAME, name);
|
||||
private Repository repository(String namespace, String name) {
|
||||
return new Repository(name, GitRepositoryHandler.TYPE_NAME, namespace, name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,34 +38,31 @@ package sonia.scm.repository.spi;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import org.eclipse.jgit.api.CommitCommand;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.transport.ScmTransportProtocol;
|
||||
import org.eclipse.jgit.transport.Transport;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.user.UserTestData;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -88,8 +85,8 @@ public class AbstractRemoteCommandTestBase
|
||||
outgoingDirectory = tempFolder.newFile("outgoing");
|
||||
outgoingDirectory.delete();
|
||||
|
||||
incomgingRepository = new Repository("1", "git", "incoming");
|
||||
outgoingRepository = new Repository("2", "git", "outgoing");
|
||||
incomgingRepository = new Repository("1", "git", "space", "incoming");
|
||||
outgoingRepository = new Repository("2", "git", "space", "outgoing");
|
||||
|
||||
incoming = Git.init().setDirectory(incomingDirectory).setBare(false).call();
|
||||
outgoing = Git.init().setDirectory(outgoingDirectory).setBare(false).call();
|
||||
|
||||
@@ -35,14 +35,15 @@ package sonia.scm.web.lfs;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import static org.mockito.Matchers.matches;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.store.BlobStoreFactory;
|
||||
|
||||
import static org.mockito.Matchers.matches;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link LfsBlobStoreFactory}.
|
||||
*
|
||||
@@ -59,7 +60,7 @@ public class LfsBlobStoreFactoryTest {
|
||||
|
||||
@Test
|
||||
public void getBlobStore() throws Exception {
|
||||
lfsBlobStoreFactory.getLfsBlobStore(new Repository("the-id", "GIT", "the-name"));
|
||||
lfsBlobStoreFactory.getLfsBlobStore(new Repository("the-id", "GIT", "space", "the-name"));
|
||||
|
||||
// just make sure the right parameter is passed, as properly validating the return value is nearly impossible with
|
||||
// the return value (and should not be part of this test)
|
||||
|
||||
@@ -7,8 +7,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Created by omilke on 18.05.2017.
|
||||
@@ -18,14 +19,15 @@ public class LfsServletFactoryTest {
|
||||
@Test
|
||||
public void buildBaseUri() throws Exception {
|
||||
|
||||
String repositoryNamespace = "space";
|
||||
String repositoryName = "git-lfs-demo";
|
||||
|
||||
String result = LfsServletFactory.buildBaseUri(new Repository("", "GIT", repositoryName), RequestWithUri(repositoryName, true));
|
||||
String result = LfsServletFactory.buildBaseUri(new Repository("", "GIT", repositoryNamespace, repositoryName), RequestWithUri(repositoryName, true));
|
||||
assertThat(result, is(equalTo("http://localhost:8081/scm/git/git-lfs-demo.git/info/lfs/objects/")));
|
||||
|
||||
|
||||
//result will be with dot-gix suffix, ide
|
||||
result = LfsServletFactory.buildBaseUri(new Repository("", "GIT", repositoryName), RequestWithUri(repositoryName, false));
|
||||
result = LfsServletFactory.buildBaseUri(new Repository("", "GIT", repositoryNamespace, repositoryName), RequestWithUri(repositoryName, false));
|
||||
assertThat(result, is(equalTo("http://localhost:8081/scm/git/git-lfs-demo.git/info/lfs/objects/")));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user