Merged 2.0.0-m3 into feature/global_config_v2_endpoint

This commit is contained in:
Johannes Schnatterer
2018-08-01 10:30:38 +02:00
358 changed files with 24149 additions and 21316 deletions

View File

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

View File

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

View File

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

View File

@@ -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)

View File

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