Search in sources :

Example 41 with GitFlowRepository

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

the class ReleaseStartOperationTest method testReleaseBranchCreatedFromCommit.

@Test
public void testReleaseBranchCreatedFromCommit() throws Exception {
    RevCommit initialCommit = testRepository.createInitialCommit("testReleaseBranchCreatedFromCommit\n\nfirst commit\n");
    testRepository.createInitialCommit("testReleaseBranchCreatedFromCommit\n\nsecond commit\n");
    Repository repository = testRepository.getRepository();
    new InitOperation(repository).execute(null);
    GitFlowRepository gfRepo = new GitFlowRepository(repository);
    ReleaseStartOperation releaseStartOperation = new ReleaseStartOperation(gfRepo, initialCommit.getName(), MY_RELEASE);
    releaseStartOperation.execute(null);
    assertNotNull(releaseStartOperation.getSchedulingRule());
    assertEquals(gfRepo.getConfig().getFullReleaseBranchName(MY_RELEASE), repository.getFullBranch());
    assertEquals(initialCommit, gfRepo.findHead());
}
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)

Example 42 with GitFlowRepository

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

the class AbstractPublishHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    try {
        int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
        CurrentBranchPublishOperation featurePublishOperation = new CurrentBranchPublishOperation(gfRepo, timeout);
        JobUtil.scheduleUserWorkspaceJob(featurePublishOperation, getProgressText(), JobFamilies.REBASE);
    } catch (CoreException e) {
        return error(e.getMessage(), e);
    }
    return null;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) CurrentBranchPublishOperation(org.eclipse.egit.gitflow.op.CurrentBranchPublishOperation) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

Example 43 with GitFlowRepository

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

the class FeatureCheckoutOperationTest method testFeatureCheckoutConflicts.

@Test
public void testFeatureCheckoutConflicts() throws Exception {
    Repository repository = testRepository.getRepository();
    GitFlowRepository gfRepo = init("testFeatureCheckoutConflicts\n\nfirst commit\n");
    // setup something we can modify later
    IFile file = testUtils.addFileToProject(project.getProject(), "folder1/file1.txt", "Hello world");
    testRepository.connect(project.getProject());
    testRepository.trackAllFiles(project.getProject());
    testRepository.commit("Initial commit");
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    // modify on first branch
    testUtils.changeContentOfFile(project.getProject(), file, "Hello Feature");
    testRepository.addToIndex(file);
    testRepository.commit("Feature commit");
    new BranchOperation(repository, gfRepo.getConfig().getDevelop()).execute(null);
    assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch());
    // modify on second branch
    testUtils.changeContentOfFile(project.getProject(), file, "Hello Develop");
    testRepository.addToIndex(file);
    FeatureCheckoutOperation featureCheckoutOperation = new FeatureCheckoutOperation(gfRepo, MY_FEATURE);
    featureCheckoutOperation.execute(null);
    assertEquals(Status.CONFLICTS, featureCheckoutOperation.getResult().getStatus());
    assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch());
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) IFile(org.eclipse.core.resources.IFile) BranchOperation(org.eclipse.egit.core.op.BranchOperation) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Test(org.junit.Test)

Example 44 with GitFlowRepository

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

the class FeatureFinishOperationTest method testFeatureFinishKeepBranch.

@Test
public void testFeatureFinishKeepBranch() throws Exception {
    Repository repository = testRepository.getRepository();
    GitFlowRepository gfRepo = init("testFeatureFinishKeepBranch\n\nfirst commit\n");
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    addFileAndCommit("foo.txt", "testFeatureFinishKeepBranch\n\nbranch commit 1\n");
    addFileAndCommit("bar.txt", "testFeatureFinishKeepBranch\n\nbranch commit 2\n");
    FeatureFinishOperation featureFinishOperation = new FeatureFinishOperation(gfRepo);
    featureFinishOperation.setKeepBranch(true);
    featureFinishOperation.execute(null);
    assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch());
    String branchName = gfRepo.getConfig().getFeatureBranchName(MY_FEATURE);
    assertNotNull(findBranch(repository, branchName));
    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)

Example 45 with GitFlowRepository

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

the class FeatureFinishOperationTest method testFeatureFinishSquash.

@Test
public void testFeatureFinishSquash() throws Exception {
    String fileName = "theFirstFile.txt";
    String fileName2 = "theSecondFile.txt";
    Repository repository = testRepository.getRepository();
    GitFlowRepository gfRepo = init("testFeatureFinishSquash\n\nfirst commit\n");
    new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
    String branchName = gfRepo.getConfig().getFeatureBranchName(MY_FEATURE);
    addFileAndCommit(fileName, "adding first file on feature branch");
    addFileAndCommit(fileName2, "adding second file on feature branch");
    FeatureFinishOperation featureFinishOperation = new FeatureFinishOperation(gfRepo);
    featureFinishOperation.setSquash(true);
    featureFinishOperation.execute(null);
    assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch());
    assertEquals(null, findBranch(repository, branchName));
    assertEquals(1, countCommits(repository));
    assertTrue(new File(repository.getDirectory() + "/../" + fileName).exists());
    assertTrue(new File(repository.getDirectory() + "/../" + fileName2).exists());
    Status status = Git.wrap(repository).status().call();
    assertTrue(status.hasUncommittedChanges());
}
Also used : Status(org.eclipse.jgit.api.Status) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) File(java.io.File) 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