Search in sources :

Example 46 with GitFlowRepository

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

the class FeatureFinishOperationTest method testFeatureFinishFastForward.

@Test
public void testFeatureFinishFastForward() throws Exception {
    String fileName = "theFirstFile.txt";
    Repository repository = testRepository.getRepository();
    GitFlowRepository gfRepo = init("testFeatureFinish\n\nfirst commit\n");
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    RevCommit branchCommit = addFileAndCommit(fileName, "adding file on feature branch");
    new FeatureFinishOperation(gfRepo).execute(null);
    assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch());
    String branchName = gfRepo.getConfig().getFeatureBranchName(MY_FEATURE);
    assertNull(findBranch(repository, branchName));
    RevCommit developHead = gfRepo.findHead();
    assertEquals(branchCommit, developHead);
    assertEquals(2, countCommits(repository));
    assertTrue(new File(repository.getDirectory() + "/../" + fileName).exists());
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 47 with GitFlowRepository

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

the class FeatureListOperationTest method testFeatureList.

@Test
public void testFeatureList() throws Exception {
    GitFlowRepository gfRepo1 = new GitFlowRepository(repository1.getRepository());
    GitFlowRepository gfRepo2 = new GitFlowRepository(repository2.getRepository());
    new FeatureStartOperation(gfRepo1, MY_FEATURE).execute(null);
    FeatureListOperation featureListOperation = new FeatureListOperation(gfRepo2, 0);
    featureListOperation.execute(null);
    String name = gfRepo2.getConfig().getFullFeatureBranchName(MY_FEATURE);
    assertNotNull(featureListOperation.getOperationResult().getAdvertisedRef(name));
    List<Ref> result = featureListOperation.getResult();
    assertEquals(1, result.size());
    assertEquals(R_REMOTES + DEFAULT_REMOTE_NAME + SEP + gfRepo2.getConfig().getFeatureBranchName(MY_FEATURE), result.get(0).getName());
}
Also used : Ref(org.eclipse.jgit.lib.Ref) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Test(org.junit.Test)

Example 48 with GitFlowRepository

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

the class FeatureRebaseOperationTest method testFeatureRebase.

@Test
public void testFeatureRebase() throws Exception {
    Repository repository = testRepository.getRepository();
    GitFlowRepository gfRepo = init("testFeatureRebase\n\nfirst commit\n");
    RevCommit initialCommit = gfRepo.findHead();
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    String branchCommitMessage = "adding first file on feature branch";
    addFileAndCommit("theFile.txt", branchCommitMessage);
    testRepository.checkoutBranch(gfRepo.getConfig().getDevelop());
    RevCommit developCommit = addFileAndCommit("theOtherFile.txt", "adding second file on develop branch");
    new FeatureCheckoutOperation(gfRepo, MY_FEATURE).execute(null);
    assertEquals(initialCommit, gfRepo.findHead().getParent(0));
    FeatureRebaseOperation featureRebaseOperation = new FeatureRebaseOperation(gfRepo);
    featureRebaseOperation.execute(null);
    RebaseResult res = featureRebaseOperation.getOperationResult();
    assertEquals(RebaseResult.Status.OK, res.getStatus());
    assertEquals(branchCommitMessage, gfRepo.findHead().getShortMessage());
    assertEquals(developCommit, parseCommit(repository, repository.resolve("HEAD^")));
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) RebaseResult(org.eclipse.jgit.api.RebaseResult) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 49 with GitFlowRepository

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

the class FeatureStartOperationTest method testFeatureStartOnMaster.

public void testFeatureStartOnMaster() throws Exception {
    Repository repository = testRepository.getRepository();
    GitFlowRepository gfRepo = init("testFeatureStartOnMaster\n\nfirst commit\n");
    BranchOperation branchOperation = new BranchOperation(repository, MY_MASTER);
    branchOperation.execute(null);
    new FeatureStartOperation(gfRepo, MY_FEATURE).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)

Example 50 with GitFlowRepository

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

the class HotfixFinishOperationTest method testHotfixFinishSingleCommit.

@Test
public void testHotfixFinishSingleCommit() throws Exception {
    testRepository.createInitialCommit("testHotfixFinish\n\nfirst commit\n");
    Repository repository = testRepository.getRepository();
    new InitOperation(repository).execute(null);
    GitFlowRepository gfRepo = new GitFlowRepository(repository);
    new HotfixStartOperation(gfRepo, MY_HOTFIX).execute(null);
    RevCommit branchCommit = testRepository.createInitialCommit("testHotfixFinish\n\nbranch commit\n");
    new HotfixFinishOperation(gfRepo).execute(null);
    assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch());
    String branchName = gfRepo.getConfig().getHotfixBranchName(MY_HOTFIX);
    // tag created?
    RevCommit taggedCommit = gfRepo.findCommitForTag(MY_HOTFIX);
    assertEquals(formatMergeCommitMessage(branchName), taggedCommit.getShortMessage());
    // branch removed?
    assertEquals(findBranch(repository, branchName), null);
    RevCommit developHead = gfRepo.findHead(DEVELOP);
    assertNotEquals(branchCommit, developHead);
    RevCommit masterHead = gfRepo.findHead(MY_MASTER);
    assertEquals(formatMergeCommitMessage(branchName), masterHead.getShortMessage());
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) RevCommit(org.eclipse.jgit.revwalk.RevCommit) 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