aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2016-08-15 07:55:44 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2016-09-15 00:44:23 +0200
commitaadbb158e10ccc3194c4e7f2c1b3885b3c40571c (patch)
tree99e91dafc7ebf198edb87c5754406ca48b7da172 /org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java
parent619329c84e41f9abe83616795d65af8c7fed5f3d (diff)
downloadjgit-aadbb158e10ccc3194c4e7f2c1b3885b3c40571c.tar.gz
jgit-aadbb158e10ccc3194c4e7f2c1b3885b3c40571c.zip
Handle all values of branch.[name].rebase
BranchConfig treated this config property as a boolean, but git also allows the values "preserve" and "interactive". Config property pull.rebase also allows the same values. Replace private enum PullCommand.PullRebaseMode by new public enum BranchConfig.BranchRebaseMode and adapt all uses. Add a new setter to PullCommand. Note: PullCommand will treat "interactive" like "true", i.e., as a non-interactive rebase. Not sure how "interactive" should be handled. At least it won't balk on it. Bug: 499482 Change-Id: I7309360f5662b2c2efa1bd8ea6f112c63cf064af Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java63
1 files changed, 41 insertions, 22 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java
index 181e4a135a..4c09a82572 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java
@@ -43,11 +43,14 @@
package org.eclipse.jgit.api;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.eclipse.jgit.junit.RepositoryTestCase;
+import org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.StoredConfig;
@@ -98,32 +101,40 @@ public class RenameBranchCommandTest extends RepositoryTestCase {
@Test
public void renameBranchSingleConfigValue() throws Exception {
StoredConfig config = git.getRepository().getConfig();
- config.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- Constants.MASTER, ConfigConstants.CONFIG_KEY_REBASE, true);
+ config.setEnum(ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER,
+ ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.REBASE);
config.save();
String branch = "b1";
- assertTrue(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- Constants.MASTER, ConfigConstants.CONFIG_KEY_REBASE, true));
- assertFalse(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- branch, ConfigConstants.CONFIG_KEY_REBASE, false));
+ assertEquals(BranchRebaseMode.REBASE,
+ config.getEnum(BranchRebaseMode.values(),
+ ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER,
+ ConfigConstants.CONFIG_KEY_REBASE,
+ BranchRebaseMode.NONE));
+ assertNull(config.getEnum(BranchRebaseMode.values(),
+ ConfigConstants.CONFIG_BRANCH_SECTION, branch,
+ ConfigConstants.CONFIG_KEY_REBASE, null));
assertNotNull(git.branchRename().setNewName(branch).call());
config = git.getRepository().getConfig();
- assertFalse(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- Constants.MASTER, ConfigConstants.CONFIG_KEY_REBASE, false));
- assertTrue(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- branch, ConfigConstants.CONFIG_KEY_REBASE, false));
+ assertNull(config.getEnum(BranchRebaseMode.values(),
+ ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER,
+ ConfigConstants.CONFIG_KEY_REBASE, null));
+ assertEquals(BranchRebaseMode.REBASE,
+ config.getEnum(BranchRebaseMode.values(),
+ ConfigConstants.CONFIG_BRANCH_SECTION, branch,
+ ConfigConstants.CONFIG_KEY_REBASE,
+ BranchRebaseMode.NONE));
}
@Test
public void renameBranchExistingSection() throws Exception {
String branch = "b1";
StoredConfig config = git.getRepository().getConfig();
- config.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- Constants.MASTER, ConfigConstants.CONFIG_KEY_REBASE, true);
+ config.setEnum(ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER,
+ ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.REBASE);
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
Constants.MASTER, "a", "a");
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, branch, "a",
@@ -140,18 +151,22 @@ public class RenameBranchCommandTest extends RepositoryTestCase {
@Test
public void renameBranchMultipleConfigValues() throws Exception {
StoredConfig config = git.getRepository().getConfig();
- config.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- Constants.MASTER, ConfigConstants.CONFIG_KEY_REBASE, true);
+ config.setEnum(ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER,
+ ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.REBASE);
config.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
Constants.MASTER, ConfigConstants.CONFIG_KEY_MERGE, true);
config.save();
String branch = "b1";
- assertTrue(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- Constants.MASTER, ConfigConstants.CONFIG_KEY_REBASE, true));
- assertFalse(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- branch, ConfigConstants.CONFIG_KEY_REBASE, false));
+ assertEquals(BranchRebaseMode.REBASE,
+ config.getEnum(BranchRebaseMode.values(),
+ ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER,
+ ConfigConstants.CONFIG_KEY_REBASE,
+ BranchRebaseMode.NONE));
+ assertNull(config.getEnum(BranchRebaseMode.values(),
+ ConfigConstants.CONFIG_BRANCH_SECTION, branch,
+ ConfigConstants.CONFIG_KEY_REBASE, null));
assertTrue(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
Constants.MASTER, ConfigConstants.CONFIG_KEY_MERGE, true));
assertFalse(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
@@ -160,10 +175,14 @@ public class RenameBranchCommandTest extends RepositoryTestCase {
assertNotNull(git.branchRename().setNewName(branch).call());
config = git.getRepository().getConfig();
- assertFalse(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- Constants.MASTER, ConfigConstants.CONFIG_KEY_REBASE, false));
- assertTrue(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
- branch, ConfigConstants.CONFIG_KEY_REBASE, false));
+ assertNull(config.getEnum(BranchRebaseMode.values(),
+ ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER,
+ ConfigConstants.CONFIG_KEY_REBASE, null));
+ assertEquals(BranchRebaseMode.REBASE,
+ config.getEnum(BranchRebaseMode.values(),
+ ConfigConstants.CONFIG_BRANCH_SECTION, branch,
+ ConfigConstants.CONFIG_KEY_REBASE,
+ BranchRebaseMode.NONE));
assertFalse(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
Constants.MASTER, ConfigConstants.CONFIG_KEY_MERGE, false));
assertTrue(config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,