Search in sources :

Example 26 with GitFlowRepository

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

the class DevelopCheckoutHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    if (gfRepo == null) {
        return error(UIText.Handlers_noGitflowRepositoryFound);
    }
    BranchOperationUI.checkout(gfRepo.getRepository(), gfRepo.getConfig().getDevelopFull()).start();
    return null;
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

Example 27 with GitFlowRepository

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

the class ReleaseStartHandler method getStartCommit.

private String getStartCommit(ExecutionEvent event) throws ExecutionException {
    ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
    IStructuredSelection selection = SelectionUtils.getStructuredSelection(currentSelection);
    if (selection.getFirstElement() instanceof PlotCommit) {
        RevCommit plotCommit = (RevCommit) selection.getFirstElement();
        return plotCommit.getName();
    } else {
        GitFlowRepository gitFlowRepository = GitFlowHandlerUtil.getRepository(event);
        if (gitFlowRepository == null) {
            throw new ExecutionException(UIText.ReleaseStartHandler_startCommitCouldNotBeDetermined);
        }
        RevCommit head;
        try {
            head = gitFlowRepository.findHead();
        } catch (WrongGitFlowStateException e) {
            throw new ExecutionException(e.getMessage(), e);
        }
        return head.getName();
    }
}
Also used : PlotCommit(org.eclipse.jgit.revplot.PlotCommit) ISelection(org.eclipse.jface.viewers.ISelection) WrongGitFlowStateException(org.eclipse.egit.gitflow.WrongGitFlowStateException) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExecutionException(org.eclipse.core.commands.ExecutionException) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 28 with GitFlowRepository

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

the class InitHandlerTest method testInitMissingMaster.

@Test
public void testInitMissingMaster() throws Exception {
    selectProject(PROJ1);
    clickInit();
    fillDialog(MASTER_BRANCH_MISSING);
    bot.waitUntil(shellIsActive(UIText.InitDialog_masterBranchIsMissing));
    bot.button("Yes").click();
    bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
    GitFlowRepository gitFlowRepository = new GitFlowRepository(repository);
    GitFlowConfig config = gitFlowRepository.getConfig();
    assertEquals(DEVELOP_BRANCH, repository.getBranch());
    assertEquals(MASTER_BRANCH_MISSING, config.getMaster());
    assertEquals(FEATURE_BRANCH_PREFIX, config.getFeaturePrefix());
    assertEquals(RELEASE_BRANCH_PREFIX, config.getReleasePrefix());
    assertEquals(HOTFIX_BRANCH_PREFIX, config.getHotfixPrefix());
    assertEquals(VERSION_TAG_PREFIX, config.getVersionTagPrefix());
    assertNotNull(repository.exactRef(Constants.R_HEADS + DEVELOP_BRANCH));
}
Also used : GitFlowConfig(org.eclipse.egit.gitflow.GitFlowConfig) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Test(org.junit.Test)

Example 29 with GitFlowRepository

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

the class FeatureFinishKeepBranchHandlerTest method testFeatureFinishKeepBranch.

@Test
public void testFeatureFinishKeepBranch() throws Exception {
    init();
    setContentAddAndCommit("bar");
    createFeature(FEATURE_NAME);
    RevCommit featureBranchCommit = setContentAddAndCommit("foo");
    checkoutBranch(DEVELOP);
    checkoutFeature(FEATURE_NAME);
    finishFeature();
    GitFlowRepository gfRepo = new GitFlowRepository(repository);
    RevCommit developHead = gfRepo.findHead();
    assertEquals(developHead, featureBranchCommit);
    assertNotNull(findBranch(gfRepo.getConfig().getFeatureBranchName(FEATURE_NAME)));
    IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
    assertFalse(prefStore.getBoolean(FEATURE_FINISH_SQUASH));
    assertTrue(prefStore.getBoolean(FEATURE_FINISH_KEEP_BRANCH));
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 30 with GitFlowRepository

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

the class FeatureFinishSquashHandlerTest method testFeatureFinishSquash.

@Test
public void testFeatureFinishSquash() throws Exception {
    int expectedCommitCount = 2;
    init();
    setContentAddAndCommit("bar");
    expectedCommitCount++;
    createFeature(FEATURE_NAME);
    RevCommit commit1 = setContentAddAndCommit("commit 1");
    expectedCommitCount++;
    RevCommit commit2 = setContentAddAndCommit("commit 2");
    expectedCommitCount++;
    checkoutBranch(DEVELOP);
    checkoutFeature(FEATURE_NAME);
    finishFeature();
    expectedCommitCount--;
    RevCommit developHead = new GitFlowRepository(repository).findHead();
    assertNotEquals(developHead, commit1);
    assertNotEquals(developHead, commit2);
    assertEquals(expectedCommitCount, countCommits());
    assertTrue(developHead.getFullMessage().startsWith(SQUASHED_COMMENT_SUMMARY));
    IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
    assertTrue(prefStore.getBoolean(FEATURE_FINISH_SQUASH));
    assertFalse(prefStore.getBoolean(FEATURE_FINISH_KEEP_BRANCH));
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) 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