use of de.catma.repository.git.interfaces.ILocalGitRepositoryManager in project catma by forTEXT.
the class JGitRepoManagerTest method init.
@Test
public void init() throws Exception {
try (ILocalGitRepositoryManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
this.directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
File testRepoPath = new File(jGitRepoManager.getRepositoryBasePath(), Randomizer.getRepoName());
jGitRepoManager.init("", testRepoPath.getName(), "Test Description");
assert jGitRepoManager.isAttached();
assert testRepoPath.exists();
assert testRepoPath.isDirectory();
assert Arrays.asList(testRepoPath.list()).contains(".git");
File gitDescriptionFile = new File(testRepoPath, ".git/description");
assertEquals("Test Description\n", new String(Files.readAllBytes(gitDescriptionFile.toPath())));
}
}
use of de.catma.repository.git.interfaces.ILocalGitRepositoryManager in project catma by forTEXT.
the class JGitRepoManagerTest method getRepositoryWorkTree.
@Test
public void getRepositoryWorkTree() throws Exception {
try (ILocalGitRepositoryManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
this.directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
assertNull(jGitRepoManager.getRepositoryWorkTree());
File testRepoPath = new File(jGitRepoManager.getRepositoryBasePath(), Randomizer.getRepoName());
jGitRepoManager.init("", testRepoPath.getName(), null);
assert jGitRepoManager.isAttached();
assert testRepoPath.exists();
assert testRepoPath.isDirectory();
assertEquals(testRepoPath, jGitRepoManager.getRepositoryWorkTree());
}
}
use of de.catma.repository.git.interfaces.ILocalGitRepositoryManager in project catma by forTEXT.
the class JGitRepoManagerTest method cloneRepo.
@Test
public void cloneRepo() throws Exception {
try (ILocalGitRepositoryManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
this.directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
// create a bare repository that will act as the remote
File testRepoPath = new File(jGitRepoManager.getRepositoryBasePath(), Randomizer.getRepoName());
try (Git gitApi = Git.init().setDirectory(testRepoPath).setBare(true).call()) {
}
// clone it
File clonedRepoPath = new File(jGitRepoManager.getRepositoryBasePath(), "cloned");
String repoName = jGitRepoManager.clone("", testRepoPath.toURI().toString(), clonedRepoPath, null, null);
assert jGitRepoManager.isAttached();
assertEquals(repoName, clonedRepoPath.getName());
assert clonedRepoPath.exists();
assert clonedRepoPath.isDirectory();
assert Arrays.asList(clonedRepoPath.list()).contains(".git");
}
}
use of de.catma.repository.git.interfaces.ILocalGitRepositoryManager in project catma by forTEXT.
the class JGitRepoManagerTest method open.
@Test
public void open() throws Exception {
try (ILocalGitRepositoryManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
this.directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
File testRepoPath = new File(jGitRepoManager.getRepositoryBasePath(), Randomizer.getRepoName());
jGitRepoManager.init("", testRepoPath.getName(), null);
assert jGitRepoManager.isAttached();
assert testRepoPath.exists();
assert testRepoPath.isDirectory();
// can't call open on an attached instance
jGitRepoManager.detach();
jGitRepoManager.open("aProject", testRepoPath.getName());
assert jGitRepoManager.isAttached();
}
}
use of de.catma.repository.git.interfaces.ILocalGitRepositoryManager in project catma by forTEXT.
the class JGitRepoManagerTest method cloneGitLabRepoWithAuthentication.
@Test
public void cloneGitLabRepoWithAuthentication() throws Exception {
GitLabServerManager gitLabServerManager = new GitLabServerManager(UserIdentification.userToMap(this.catmaUser.getIdentifier()));
String randomRepoName = Randomizer.getRepoName();
IRemoteGitServerManager.CreateRepositoryResponse createRepositoryResponse = gitLabServerManager.createRepository(randomRepoName, null);
try (ILocalGitRepositoryManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
this.directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
String repoName = jGitRepoManager.clone("", createRepositoryResponse.repositoryHttpUrl, null, gitLabServerManager.getUsername(), gitLabServerManager.getPassword());
assert jGitRepoManager.isAttached();
assertEquals(repoName, randomRepoName);
File testRepoPath = new File(jGitRepoManager.getRepositoryBasePath(), repoName);
assert testRepoPath.exists();
assert testRepoPath.isDirectory();
assert Arrays.asList(testRepoPath.list()).contains(".git");
}
// cleanup (these are not handled by tearDown)
gitLabServerManager.deleteRepository(createRepositoryResponse.repositoryId);
await().until(() -> gitLabServerManager.getAdminGitLabApi().getProjectApi().getProjects().isEmpty());
// see GitLabServerManagerTest tearDown() for more info
User user = gitLabServerManager.getGitLabUser();
gitLabServerManager.getAdminGitLabApi().getUserApi().deleteUser(user.getId());
GitLabServerManagerTest.awaitUserDeleted(gitLabServerManager.getAdminGitLabApi().getUserApi(), user.getId());
}
Aggregations