Search in sources :

Example 11 with GitFlowRepository

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

the class GitFlowHandlerUtil method gatherRevision.

static String gatherRevision(ExecutionEvent event) throws IOException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    if (gfRepo == null) {
        throw new IllegalStateException(// $NON-NLS-1$
        "Gitflow command called with no Gitflow repository present");
    }
    Ref develop = gfRepo.getRepository().exactRef(gfRepo.getConfig().getDevelopFull());
    if (develop == null) {
        throw new IllegalStateException(// $NON-NLS-1$
        "Gitflow command called on Gitflow repository with no develop branch. " + // $NON-NLS-1$
        "The Gitflow configuration is either corrupt or incomplete.");
    }
    return develop.getName();
}
Also used : Ref(org.eclipse.jgit.lib.Ref) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

Example 12 with GitFlowRepository

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

the class HotfixFinishHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    if (gfRepo == null) {
        return error(UIText.Handlers_noGitflowRepositoryFound);
    }
    HotfixFinishOperation hotfixFinishOperation;
    try {
        hotfixFinishOperation = new HotfixFinishOperation(gfRepo);
        String hotfixBranch = gfRepo.getRepository().getBranch();
        String develop = gfRepo.getConfig().getDevelop();
        JobUtil.scheduleUserWorkspaceJob(hotfixFinishOperation, UIText.HotfixFinishHandler_finishingHotfix, JobFamilies.GITFLOW_FAMILY);
        IJobManager jobMan = Job.getJobManager();
        jobMan.join(JobFamilies.GITFLOW_FAMILY, null);
        MergeResult mergeResult = hotfixFinishOperation.getMergeResult();
        MergeStatus mergeStatus = mergeResult.getMergeStatus();
        if (!MergeStatus.CONFLICTING.equals(mergeStatus)) {
            return null;
        }
        if (handleConflictsOnMaster(gfRepo)) {
            return null;
        }
        MultiStatus status = createMergeConflictInfo(develop, hotfixBranch, mergeResult);
        ErrorDialog.openError(null, UIText.HotfixFinishHandler_Conflicts, null, status);
    } catch (WrongGitFlowStateException | CoreException | IOException | OperationCanceledException | InterruptedException e) {
        return error(e.getMessage(), e);
    }
    return null;
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) MergeResult(org.eclipse.jgit.api.MergeResult) MultiStatus(org.eclipse.core.runtime.MultiStatus) IJobManager(org.eclipse.core.runtime.jobs.IJobManager) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) MergeStatus(org.eclipse.jgit.api.MergeResult.MergeStatus) WrongGitFlowStateException(org.eclipse.egit.gitflow.WrongGitFlowStateException) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) HotfixFinishOperation(org.eclipse.egit.gitflow.op.HotfixFinishOperation)

Example 13 with GitFlowRepository

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

the class CurrentBranchPublishOperationTest method testFeaturePublish.

@Test
public void testFeaturePublish() throws Exception {
    new InitOperation(repository2.getRepository()).execute(null);
    GitFlowRepository gfRepo2 = new GitFlowRepository(repository2.getRepository());
    new FeatureStartOperation(gfRepo2, MY_FEATURE).execute(null);
    RevCommit branchCommit = repository2.createInitialCommit("testFeaturePublish");
    CurrentBranchPublishOperation featurePublishOperation = new CurrentBranchPublishOperation(gfRepo2, 0);
    featurePublishOperation.execute(null);
    PushOperationResult result = featurePublishOperation.getOperationResult();
    assertTrue(result.isSuccessfulConnection(repository1.getUri()));
    PushResult pushResult = result.getPushResult(repository1.getUri());
    assertEquals(RefUpdate.Result.NEW, pushResult.getTrackingRefUpdates().iterator().next().getResult());
    assertCommitArrivedAtRemote(branchCommit, repository1.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 : PushOperationResult(org.eclipse.egit.core.op.PushOperationResult) PushResult(org.eclipse.jgit.transport.PushResult) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 14 with GitFlowRepository

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

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

the class FeatureFinishOperationTest method testFeatureFinish.

@Test
public void testFeatureFinish() throws Exception {
    Repository repository = testRepository.getRepository();
    GitFlowRepository gfRepo = init("testFeatureFinish\n\nfirst commit\n");
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    addFileAndCommit("foo.txt", "testFeatureFinish\n\nbranch commit 1\n");
    addFileAndCommit("bar.txt", "testFeatureFinish\n\nbranch commit 2\n");
    new FeatureFinishOperation(gfRepo).execute(null);
    assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch());
    String branchName = gfRepo.getConfig().getFeatureBranchName(MY_FEATURE);
    assertEquals(formatMergeCommitMessage(branchName) + " into develop", gfRepo.findHead().getFullMessage());
}
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