Search in sources :

Example 16 with GitFlowRepository

use of org.eclipse.egit.gitflow.GitFlowRepository 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 17 with GitFlowRepository

use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.

the class FeatureStartOperationTest method testFeatureStart.

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

Example 18 with GitFlowRepository

use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.

the class FeatureTrackOperationTest method testFeatureTrack.

@Test
public void testFeatureTrack() throws Exception {
    GitFlowRepository gfRepo1 = new GitFlowRepository(repository1.getRepository());
    GitFlowRepository gfRepo2 = new GitFlowRepository(repository2.getRepository());
    new FeatureStartOperation(gfRepo1, MY_FEATURE).execute(null);
    RevCommit branchCommit = repository1.createInitialCommit("testFeatureTrack");
    FeatureTrackOperation featureTrackOperation = new FeatureTrackOperation(gfRepo2, getFirstRemoteFeatureRef(gfRepo2), NO_TIMEOUT);
    featureTrackOperation.execute(null);
    FetchResult operationResult = featureTrackOperation.getOperationResult();
    assertNotNull(operationResult.getAdvertisedRef(gfRepo2.getConfig().getFullFeatureBranchName(MY_FEATURE)));
    assertEquals(gfRepo2.getConfig().getFeatureBranchName(MY_FEATURE), repository2.getRepository().getBranch());
    assertEquals(branchCommit, findHead(repository2.getRepository()));
    RevCommit localCommit = repository2.createInitialCommit("testFeatureTrack2");
    new CurrentBranchPublishOperation(gfRepo2, 0).execute(null);
    assertEquals(localCommit, findHead(repository2.getRepository()));
    // config updated?
    assertEquals(DEFAULT_REMOTE_NAME, getRemoteName(gfRepo2, MY_FEATURE));
    assertEquals(R_HEADS + gfRepo2.getConfig().getFeatureBranchName(MY_FEATURE), gfRepo2.getUpstreamBranchName(MY_FEATURE));
}
Also used : FetchResult(org.eclipse.jgit.transport.FetchResult) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 19 with GitFlowRepository

use of org.eclipse.egit.gitflow.GitFlowRepository 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 20 with GitFlowRepository

use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.

the class HotfixStartOperationTest method testHotfixStart.

@Test
public void testHotfixStart() throws Exception {
    testRepository.createInitialCommit("testHotfixStart\n\nfirst commit\n");
    Repository repository = testRepository.getRepository();
    new InitOperation(repository).execute(null);
    GitFlowRepository gfRepo = new GitFlowRepository(repository);
    HotfixStartOperation hotfixStartOperation = new HotfixStartOperation(gfRepo, MY_HOTFIX);
    assertNull(hotfixStartOperation.getSchedulingRule());
    hotfixStartOperation.execute(null);
    assertEquals(gfRepo.getConfig().getFullHotfixBranchName(MY_HOTFIX), repository.getFullBranch());
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Test(org.junit.Test)

Aggregations

GitFlowRepository (org.eclipse.egit.gitflow.GitFlowRepository)57 Repository (org.eclipse.jgit.lib.Repository)35 Test (org.junit.Test)33 RevCommit (org.eclipse.jgit.revwalk.RevCommit)19 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)7 BranchOperation (org.eclipse.egit.core.op.BranchOperation)7 IOException (java.io.IOException)6 CoreException (org.eclipse.core.runtime.CoreException)6 Shell (org.eclipse.swt.widgets.Shell)6 IJobManager (org.eclipse.core.runtime.jobs.IJobManager)5 WrongGitFlowStateException (org.eclipse.egit.gitflow.WrongGitFlowStateException)5 File (java.io.File)4 Ref (org.eclipse.jgit.lib.Ref)4 GitFlowConfig (org.eclipse.egit.gitflow.GitFlowConfig)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 ExecutionException (org.eclipse.core.commands.ExecutionException)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 InitParameters (org.eclipse.egit.gitflow.InitParameters)2 FeatureBranchSelectionDialog (org.eclipse.egit.gitflow.ui.internal.dialogs.FeatureBranchSelectionDialog)2 InputDialog (org.eclipse.jface.dialogs.InputDialog)2