diff options
author | Max Hohenegger | 2015-04-30 09:48:23 +0000 |
---|---|---|
committer | Matthias Sohn | 2015-05-15 21:04:42 +0000 |
commit | 9904bd578ea60f3d28f38fec69af0456af805b12 (patch) | |
tree | 1ff9f0de63f988efae28eb2815cfb8772fce54cb /org.eclipse.egit.gitflow.test/src/org/eclipse/egit/gitflow/op/HotfixFinishOperationTest.java | |
parent | 12a6299909b1bda6a3a4957aa0d6e2c89869c18f (diff) | |
download | egit-9904bd578ea60f3d28f38fec69af0456af805b12.tar.gz egit-9904bd578ea60f3d28f38fec69af0456af805b12.tar.xz egit-9904bd578ea60f3d28f38fec69af0456af805b12.zip |
Extend EGit to allow use of git-flow
Initial implementation:
- Operations for all commonly used git flow commands without optional
parameters
- Menu contributions in the repository and history view, as well as the
team menu on projects
- Added new feature as incubation project to update site
- Non-UI tests (see launch config)
CQ: 9662
Bug: 348610
Change-Id: I215ed28e6434a789fa7260d7072532b402a1e714
Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.gitflow.test/src/org/eclipse/egit/gitflow/op/HotfixFinishOperationTest.java')
-rw-r--r-- | org.eclipse.egit.gitflow.test/src/org/eclipse/egit/gitflow/op/HotfixFinishOperationTest.java | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/org.eclipse.egit.gitflow.test/src/org/eclipse/egit/gitflow/op/HotfixFinishOperationTest.java b/org.eclipse.egit.gitflow.test/src/org/eclipse/egit/gitflow/op/HotfixFinishOperationTest.java new file mode 100644 index 0000000000..f7121845f8 --- /dev/null +++ b/org.eclipse.egit.gitflow.test/src/org/eclipse/egit/gitflow/op/HotfixFinishOperationTest.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (C) 2015, Max Hohenegger <eclipse@hohenegger.eu> + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.gitflow.op; + +import static org.eclipse.egit.gitflow.GitFlowDefaults.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import java.io.File; + +import org.eclipse.egit.core.op.BranchOperation; +import org.eclipse.egit.gitflow.GitFlowRepository; +import org.eclipse.jgit.api.MergeResult; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.revwalk.RevCommit; +import org.junit.Test; + +public class HotfixFinishOperationTest extends AbstractGitFlowOperationTest { + @Test + public void testHotfixFinish() throws Exception { + testRepository + .createInitialCommit("testHotfixFinish\n\nfirst commit\n"); + + Repository repository = testRepository.getRepository(); + new InitOperation(repository).execute(null); + GitFlowRepository gfRepo = new GitFlowRepository(repository); + + new HotfixStartOperation(gfRepo, MY_HOTFIX).execute(null); + + RevCommit branchCommit = testRepository + .createInitialCommit("testHotfixFinish\n\nbranch commit\n"); + + new HotfixFinishOperation(gfRepo).execute(null); + + assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch()); + + String branchName = gfRepo.getConfig().getHotfixBranchName(MY_HOTFIX); + + // tag created? + assertEquals(branchCommit, gfRepo.findCommitForTag(MY_HOTFIX)); + + // branch removed? + assertEquals(findBranch(repository, branchName), null); + + RevCommit developHead = gfRepo.findHead(DEVELOP); + assertEquals(branchCommit, developHead); + + RevCommit masterHead = gfRepo.findHead(MY_MASTER); + assertEquals(branchCommit, masterHead); + } + + @Test + public void testMergeToDevelopFail() throws Exception { + testRepository + .createInitialCommit("testMergeToDevelopFail\n\nfirst commit\n"); + + Repository repository = testRepository.getRepository(); + new InitOperation(repository).execute(null); + GitFlowRepository gfRepo = new GitFlowRepository(repository); + + // setup something we can modify later + File file = testRepository.createFile(project.getProject(), + "folder1/file1.txt"); + + new ReleaseStartOperation(gfRepo, MY_RELEASE).execute(null); + + testRepository.appendContentAndCommit(project.getProject(), file, + "Hello Release", "Release Commit"); + + new ReleaseFinishOperation(gfRepo).execute(null); + + new HotfixStartOperation(gfRepo, MY_HOTFIX).execute(null); + // modify on first branch + RevCommit hotfixCommit = testRepository.appendContentAndCommit( + project.getProject(), file, "Hello Hotfix", "Hotfix Commit"); + new BranchOperation(repository, gfRepo.getConfig().getDevelop()).execute(null); + assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch()); + + // modify on second branch + RevCommit developCommit = testRepository.appendContentAndCommit( + project.getProject(), file, "Hello Develop", "Develop Commit"); + + String branchName = gfRepo.getConfig().getHotfixBranchName(MY_HOTFIX); + new BranchOperation(repository, branchName).execute(null); + HotfixFinishOperation hotfixFinishOperation = new HotfixFinishOperation( + gfRepo); + hotfixFinishOperation.execute(null); + + // tag not created? + assertNotEquals(hotfixCommit, gfRepo.findCommitForTag(MY_HOTFIX)); + + // branch not removed? + assertNotEquals(findBranch(repository, branchName), null); + + // not merged on develop => conflict + RevCommit developHead = gfRepo.findHead(DEVELOP); + assertEquals(developCommit, developHead); + assertEquals(MergeResult.MergeStatus.CONFLICTING, hotfixFinishOperation + .getOperationResult().getMergeStatus()); + + // merged on master + RevCommit masterHead = gfRepo.findHead(MY_MASTER); + assertEquals(hotfixCommit, masterHead); + + assertEquals(gfRepo.getConfig().getDevelopFull(), repository.getFullBranch()); + } +} |