Search in sources :

Example 1 with ILocalGitRepositoryManager

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())));
    }
}
Also used : ILocalGitRepositoryManager(de.catma.repository.git.interfaces.ILocalGitRepositoryManager) File(java.io.File) Test(org.junit.Test)

Example 2 with ILocalGitRepositoryManager

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());
    }
}
Also used : ILocalGitRepositoryManager(de.catma.repository.git.interfaces.ILocalGitRepositoryManager) File(java.io.File) Test(org.junit.Test)

Example 3 with ILocalGitRepositoryManager

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");
    }
}
Also used : Git(org.eclipse.jgit.api.Git) ILocalGitRepositoryManager(de.catma.repository.git.interfaces.ILocalGitRepositoryManager) File(java.io.File) Test(org.junit.Test)

Example 4 with ILocalGitRepositoryManager

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();
    }
}
Also used : ILocalGitRepositoryManager(de.catma.repository.git.interfaces.ILocalGitRepositoryManager) File(java.io.File) Test(org.junit.Test)

Example 5 with ILocalGitRepositoryManager

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());
}
Also used : User(org.gitlab4j.api.models.User) ILocalGitRepositoryManager(de.catma.repository.git.interfaces.ILocalGitRepositoryManager) File(java.io.File) IRemoteGitServerManager(de.catma.repository.git.interfaces.IRemoteGitServerManager) Test(org.junit.Test)

Aggregations

ILocalGitRepositoryManager (de.catma.repository.git.interfaces.ILocalGitRepositoryManager)107 File (java.io.File)56 JGitRepoManager (de.catma.repository.git.managers.JGitRepoManager)22 MergeResult (org.eclipse.jgit.api.MergeResult)19 ContentInfoSet (de.catma.document.source.ContentInfoSet)18 Test (org.junit.Test)18 Path (java.nio.file.Path)15 AnnotationCollectionReference (de.catma.document.annotation.AnnotationCollectionReference)13 GitLabServerManagerTest (de.catma.repository.git.managers.GitLabServerManagerTest)13 JsonLdWebAnnotation (de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation)13 SourceDocument (de.catma.document.source.SourceDocument)11 SourceDocumentInfo (de.catma.document.source.SourceDocumentInfo)11 IDGenerator (de.catma.util.IDGenerator)11 AnnotationCollection (de.catma.document.annotation.AnnotationCollection)10 TagReference (de.catma.document.annotation.TagReference)10 RBACRole (de.catma.rbac.RBACRole)10 Pair (de.catma.util.Pair)10 ProgressListener (de.catma.backgroundservice.ProgressListener)9 Comment (de.catma.document.comment.Comment)9 Reply (de.catma.document.comment.Reply)9