Search in sources :

Example 6 with InitOperation

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

use of org.eclipse.egit.gitflow.op.InitOperation in project egit by eclipse.

the class BranchNameValidatorTest method testFeatureExists.

@Test
public void testFeatureExists() throws Exception {
    testRepository.createInitialCommit("testInitOperation\n\nfirst commit\n");
    Repository repository = testRepository.getRepository();
    new InitOperation(repository).execute(null);
    GitFlowRepository gfRepo = new GitFlowRepository(repository);
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    assertTrue(featureExists(gfRepo, MY_FEATURE));
}
Also used : Repository(org.eclipse.jgit.lib.Repository) InitOperation(org.eclipse.egit.gitflow.op.InitOperation) FeatureStartOperation(org.eclipse.egit.gitflow.op.FeatureStartOperation) Test(org.junit.Test) AbstractGitFlowOperationTest(org.eclipse.egit.gitflow.op.AbstractGitFlowOperationTest)

Example 8 with InitOperation

use of org.eclipse.egit.gitflow.op.InitOperation in project egit by eclipse.

the class GitFlowRepositoryConfigTest method testIsInitialized.

@Test
public void testIsInitialized() throws Exception {
    repository1.createInitialCommit("testIsInitialized\n\nfirst commit\n");
    Repository repository = repository2.getRepository();
    GitFlowConfig gitFlowConfig = new GitFlowConfig(repository);
    assertFalse(gitFlowConfig.isInitialized());
    new InitOperation(repository).execute(null);
    assertTrue(gitFlowConfig.isInitialized());
}
Also used : Repository(org.eclipse.jgit.lib.Repository) InitOperation(org.eclipse.egit.gitflow.op.InitOperation) Test(org.junit.Test)

Example 9 with InitOperation

use of org.eclipse.egit.gitflow.op.InitOperation in project egit by eclipse.

the class GitFlowRepositoryTest method testGetFeatureBranchName.

@Test
public void testGetFeatureBranchName() throws Exception {
    repository1.createInitialCommit("testGetFeatureBranchName\n\nfirst commit\n");
    Repository repository = repository1.getRepository();
    GitFlowRepository gfRepo = new GitFlowRepository(repository);
    InitParameters initParameters = new InitParameters();
    initParameters.setDevelop(DEVELOP);
    initParameters.setMaster(GitFlowDefaults.MASTER);
    initParameters.setFeature(FEATURE_PREFIX);
    initParameters.setRelease(RELEASE_PREFIX);
    initParameters.setHotfix(HOTFIX_PREFIX);
    initParameters.setVersionTag(VERSION_TAG);
    new InitOperation(repository, initParameters).execute(null);
    assertTrue(gfRepo.getFeatureBranches().isEmpty());
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    Ref actualFeatureRef = repository.exactRef(R_HEADS + gfRepo.getConfig().getFeaturePrefix() + MY_FEATURE);
    assertEquals(MY_FEATURE, gfRepo.getFeatureBranchName(actualFeatureRef));
}
Also used : TestRepository(org.eclipse.egit.core.test.TestRepository) Repository(org.eclipse.jgit.lib.Repository) Ref(org.eclipse.jgit.lib.Ref) InitOperation(org.eclipse.egit.gitflow.op.InitOperation) FeatureStartOperation(org.eclipse.egit.gitflow.op.FeatureStartOperation) Test(org.junit.Test)

Example 10 with InitOperation

use of org.eclipse.egit.gitflow.op.InitOperation in project egit by eclipse.

the class GitFlowRepositoryTest method testGetFeatureBranches.

@Test
public void testGetFeatureBranches() throws Exception {
    repository1.createInitialCommit("testGetFeatureBranches\n\nfirst commit\n");
    Repository repository = repository1.getRepository();
    GitFlowRepository gfRepo = new GitFlowRepository(repository);
    new InitOperation(repository).execute(null);
    assertTrue(gfRepo.getFeatureBranches().isEmpty());
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    assertEquals(R_HEADS + gfRepo.getConfig().getFeaturePrefix() + MY_FEATURE, gfRepo.getFeatureBranches().get(0).getName());
}
Also used : TestRepository(org.eclipse.egit.core.test.TestRepository) Repository(org.eclipse.jgit.lib.Repository) InitOperation(org.eclipse.egit.gitflow.op.InitOperation) FeatureStartOperation(org.eclipse.egit.gitflow.op.FeatureStartOperation) Test(org.junit.Test)

Aggregations

InitOperation (org.eclipse.egit.gitflow.op.InitOperation)10 Repository (org.eclipse.jgit.lib.Repository)10 Test (org.junit.Test)9 TestRepository (org.eclipse.egit.core.test.TestRepository)5 ReleaseStartOperation (org.eclipse.egit.gitflow.op.ReleaseStartOperation)4 AbstractGitFlowOperationTest (org.eclipse.egit.gitflow.op.AbstractGitFlowOperationTest)3 FeatureStartOperation (org.eclipse.egit.gitflow.op.FeatureStartOperation)3 GitFlowRepository (org.eclipse.egit.gitflow.GitFlowRepository)1 HotfixStartOperation (org.eclipse.egit.gitflow.op.HotfixStartOperation)1 ReleaseFinishOperation (org.eclipse.egit.gitflow.op.ReleaseFinishOperation)1 InitDialog (org.eclipse.egit.gitflow.ui.internal.dialogs.InitDialog)1 Ref (org.eclipse.jgit.lib.Ref)1 Shell (org.eclipse.swt.widgets.Shell)1