Search in sources :

Example 51 with GitFlowRepository

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

the class InitOperationTest method testInit.

@Test
public void testInit() throws Exception {
    testRepository.createInitialCommit("testInitOperation\n\nfirst commit\n");
    Repository repository = testRepository.getRepository();
    InitOperation initOperation = new InitOperation(repository);
    initOperation.execute(null);
    GitFlowRepository gfRepo = new GitFlowRepository(repository);
    assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch());
    assertPrefixEquals(FEATURE_PREFIX, FEATURE_KEY, repository);
    assertPrefixEquals(RELEASE_PREFIX, RELEASE_KEY, repository);
    assertPrefixEquals(HOTFIX_PREFIX, HOTFIX_KEY, repository);
    // TODO this below is unstable and I have no idea why.
    // Sometimes it receives null instead of the empty string
    // assertPrefixEquals(VERSION_TAG, VERSION_TAG_KEY, repository);
    assertBranchEquals(DEVELOP, DEVELOP_KEY, repository);
    assertBranchEquals(MASTER, MASTER_KEY, repository);
}
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 52 with GitFlowRepository

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

the class HotfixStartHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    InputDialog inputDialog = new InputDialog(HandlerUtil.getActiveShell(event), UIText.HotfixStartHandler_provideHotfixName, UIText.HotfixStartHandler_pleaseProvideANameForTheNewHotfix, // $NON-NLS-1$
    "", new HotfixNameValidator(gfRepo));
    if (inputDialog.open() != Window.OK) {
        return null;
    }
    final String hotfixName = inputDialog.getValue();
    HotfixStartOperation hotfixStartOperation = new HotfixStartOperation(gfRepo, hotfixName);
    JobUtil.scheduleUserWorkspaceJob(hotfixStartOperation, UIText.HotfixStartHandler_startingNewHotfix, JobFamilies.GITFLOW_FAMILY);
    return null;
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) HotfixStartOperation(org.eclipse.egit.gitflow.op.HotfixStartOperation) HotfixNameValidator(org.eclipse.egit.gitflow.ui.internal.validation.HotfixNameValidator) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

Example 53 with GitFlowRepository

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

the class InitHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell activeShell = HandlerUtil.getActiveShell(event);
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    if (gfRepo == null) {
        return null;
    }
    Repository repository = gfRepo.getRepository();
    if (!gfRepo.hasBranches()) {
        boolean createMaster = openQuestion(activeShell, UIText.InitHandler_emptyRepository, UIText.InitHandler_doYouWantToInitNow);
        if (!createMaster) {
            return null;
        }
        createInitialCommit(repository);
    }
    InitDialog dialog = new InitDialog(activeShell, gfRepo, getBranches(repository));
    if (dialog.open() != Window.OK) {
        return null;
    }
    InitOperation initOperation = new InitOperation(repository, dialog.getResult());
    JobUtil.scheduleUserWorkspaceJob(initOperation, UIText.InitHandler_initializing, JobFamilies.GITFLOW_FAMILY);
    return null;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) InitOperation(org.eclipse.egit.gitflow.op.InitOperation) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) InitDialog(org.eclipse.egit.gitflow.ui.internal.dialogs.InitDialog)

Example 54 with GitFlowRepository

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

the class ReleaseFinishHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    if (gfRepo == null) {
        return error(UIText.Handlers_noGitflowRepositoryFound);
    }
    final ReleaseFinishOperation releaseFinishOperation;
    try {
        releaseFinishOperation = new ReleaseFinishOperation(gfRepo);
        String releaseBranch = gfRepo.getRepository().getBranch();
        String develop = gfRepo.getConfig().getDevelop();
        JobUtil.scheduleUserWorkspaceJob(releaseFinishOperation, UIText.ReleaseFinishHandler_finishingRelease, JobFamilies.GITFLOW_FAMILY);
        IJobManager jobMan = Job.getJobManager();
        jobMan.join(JobFamilies.GITFLOW_FAMILY, null);
        MergeResult mergeResult = releaseFinishOperation.getMergeResult();
        MergeStatus mergeStatus = mergeResult.getMergeStatus();
        if (!MergeStatus.CONFLICTING.equals(mergeStatus)) {
            return null;
        }
        if (handleConflictsOnMaster(gfRepo)) {
            return null;
        }
        MultiStatus status = createMergeConflictInfo(develop, releaseBranch, mergeResult);
        ErrorDialog.openError(null, UIText.ReleaseFinishHandler_Conflicts, null, status);
    } catch (WrongGitFlowStateException | CoreException | IOException | OperationCanceledException | InterruptedException e) {
        return error(e.getMessage(), e);
    }
    return null;
}
Also used : ReleaseFinishOperation(org.eclipse.egit.gitflow.op.ReleaseFinishOperation) 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)

Example 55 with GitFlowRepository

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

the class ReleaseStartHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    final String startCommitSha1 = getStartCommit(event);
    Shell activeShell = HandlerUtil.getActiveShell(event);
    doExecute(gfRepo, startCommitSha1, activeShell);
    return null;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

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