Search in sources :

Example 6 with BranchOperation

use of org.eclipse.egit.core.op.BranchOperation in project egit by eclipse.

the class AbstractDualRepositoryTestCase method assertCommitArrivedAtRemote.

protected void assertCommitArrivedAtRemote(RevCommit branchCommit, Repository remote) throws CoreException {
    GitFlowRepository gfRepo = new GitFlowRepository(remote);
    BranchOperation checkoutOperation = new BranchOperation(remote, gfRepo.getConfig().getFullFeatureBranchName(MY_FEATURE));
    checkoutOperation.execute(null);
    RevCommit developHead = findHead(remote);
    assertEquals(branchCommit, developHead);
}
Also used : BranchOperation(org.eclipse.egit.core.op.BranchOperation) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 7 with BranchOperation

use of org.eclipse.egit.core.op.BranchOperation in project egit by eclipse.

the class FeatureCheckoutOperationTest method testFeatureCheckout.

@Test
public void testFeatureCheckout() throws Exception {
    Repository repository = testRepository.getRepository();
    GitFlowRepository gfRepo = init("testFeatureCheckout\n\nfirst commit\n");
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    new BranchOperation(repository, gfRepo.getConfig().getDevelop()).execute(null);
    new FeatureCheckoutOperation(gfRepo, MY_FEATURE).execute(null);
    assertEquals(gfRepo.getConfig().getFullFeatureBranchName(MY_FEATURE), repository.getFullBranch());
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) BranchOperation(org.eclipse.egit.core.op.BranchOperation) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Test(org.junit.Test)

Example 8 with BranchOperation

use of org.eclipse.egit.core.op.BranchOperation in project egit by eclipse.

the class FeatureFinishOperationTest method testFeatureFinishFail.

@Test(expected = WrongGitFlowStateException.class)
public void testFeatureFinishFail() throws Exception {
    Repository repository = testRepository.getRepository();
    GitFlowRepository gfRepo = init("testFeatureFinishFail\n\nfirst commit\n");
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    new BranchOperation(repository, gfRepo.getConfig().getDevelop()).execute(null);
    new FeatureFinishOperation(gfRepo).execute(null);
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) BranchOperation(org.eclipse.egit.core.op.BranchOperation) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Test(org.junit.Test)

Example 9 with BranchOperation

use of org.eclipse.egit.core.op.BranchOperation in project egit by eclipse.

the class HotfixFinishOperationTest method testMergeToDevelopFail.

@Test
public void testMergeToDevelopFail() throws Exception {
    testRepository.createInitialCommit("testMergeToDevelopFail\n\nfirst commit\n");
    Repository repository = testRepository.getRepository();
    new InitOperation(repository).execute(null);
    GitFlowRepository gfRepo = new GitFlowRepository(repository);
    // setup something we can modify later
    File file = testRepository.createFile(project.getProject(), "folder1/file1.txt");
    new ReleaseStartOperation(gfRepo, MY_RELEASE).execute(null);
    testRepository.appendContentAndCommit(project.getProject(), file, "Hello Release", "Release Commit");
    testRepository.appendContentAndCommit(project.getProject(), file, "Hello Merge Commit", "Release Commit 2");
    new ReleaseFinishOperation(gfRepo).execute(null);
    new HotfixStartOperation(gfRepo, MY_HOTFIX).execute(null);
    // modify on first branch
    testRepository.appendContentAndCommit(project.getProject(), file, "Hello Hotfix", "Hotfix Commit");
    new BranchOperation(repository, gfRepo.getConfig().getDevelop()).execute(null);
    assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch());
    // modify on second branch
    RevCommit developCommit = testRepository.appendContentAndCommit(project.getProject(), file, "Hello Develop", "Develop Commit");
    String branchName = gfRepo.getConfig().getHotfixBranchName(MY_HOTFIX);
    new BranchOperation(repository, branchName).execute(null);
    HotfixFinishOperation hotfixFinishOperation = new HotfixFinishOperation(gfRepo);
    hotfixFinishOperation.execute(null);
    // TODO: check if the reference implementation cleans up in this case
    assertNotNull(gfRepo.findCommitForTag(MY_HOTFIX));
    // branch not removed?
    assertNotEquals(findBranch(repository, branchName), null);
    // not merged on develop => conflict
    RevCommit developHead = gfRepo.findHead(DEVELOP);
    assertEquals(developCommit, developHead);
    assertEquals(MergeResult.MergeStatus.CONFLICTING, hotfixFinishOperation.getMergeResult().getMergeStatus());
    // merged on master
    RevCommit masterHead = gfRepo.findHead(MY_MASTER);
    assertEquals(String.format("Merge branch '%s'", branchName), masterHead.getFullMessage());
    assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch());
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) BranchOperation(org.eclipse.egit.core.op.BranchOperation) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 10 with BranchOperation

use of org.eclipse.egit.core.op.BranchOperation in project egit by eclipse.

the class ReleaseFinishOperationTest method testReleaseFinishFail.

@Test
public void testReleaseFinishFail() throws Exception {
    testRepository.createInitialCommit("testReleaseFinishFail\n\nfirst commit\n");
    Repository repository = testRepository.getRepository();
    new InitOperation(repository).execute(null);
    GitFlowRepository gfRepo = new GitFlowRepository(repository);
    new ReleaseStartOperation(gfRepo, MY_RELEASE).execute(null);
    new BranchOperation(repository, gfRepo.getConfig().getDevelop()).execute(null);
    try {
        new ReleaseFinishOperation(gfRepo).execute(null);
        fail();
    } catch (WrongGitFlowStateException e) {
    // success
    }
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) BranchOperation(org.eclipse.egit.core.op.BranchOperation) WrongGitFlowStateException(org.eclipse.egit.gitflow.WrongGitFlowStateException) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Test(org.junit.Test)

Aggregations

BranchOperation (org.eclipse.egit.core.op.BranchOperation)19 Test (org.junit.Test)8 CreateLocalBranchOperation (org.eclipse.egit.core.op.CreateLocalBranchOperation)7 GitFlowRepository (org.eclipse.egit.gitflow.GitFlowRepository)7 Repository (org.eclipse.jgit.lib.Repository)7 SubMonitor (org.eclipse.core.runtime.SubMonitor)5 File (java.io.File)3 IOException (java.io.IOException)3 CoreException (org.eclipse.core.runtime.CoreException)3 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 IFile (org.eclipse.core.resources.IFile)2 CommitOperation (org.eclipse.egit.core.op.CommitOperation)2 DeleteBranchOperation (org.eclipse.egit.core.op.DeleteBranchOperation)2 WrongGitFlowStateException (org.eclipse.egit.gitflow.WrongGitFlowStateException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1