diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2016-08-15 07:55:44 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-09-15 00:44:23 +0200 |
commit | aadbb158e10ccc3194c4e7f2c1b3885b3c40571c (patch) | |
tree | 99e91dafc7ebf198edb87c5754406ca48b7da172 /org.eclipse.jgit.test | |
parent | 619329c84e41f9abe83616795d65af8c7fed5f3d (diff) | |
download | jgit-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')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java | 32 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java | 63 |
2 files changed, 58 insertions, 37 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java index ce11e1b1bc..8a728caf73 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java @@ -62,6 +62,7 @@ import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.errors.NoWorkTreeException; import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.junit.TestRepository; +import org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -605,11 +606,10 @@ public class CloneCommandTest extends RepositoryTestCase { command.setURI(fileUri()); Git git2 = command.call(); addRepoToClose(git2.getRepository()); - assertFalse(git2 - .getRepository() - .getConfig() - .getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, "test", - ConfigConstants.CONFIG_KEY_REBASE, false)); + assertNull(git2.getRepository().getConfig().getEnum( + BranchRebaseMode.values(), + ConfigConstants.CONFIG_BRANCH_SECTION, "test", + ConfigConstants.CONFIG_KEY_REBASE, null)); FileBasedConfig userConfig = SystemReader.getInstance().openUserConfig( null, git.getRepository().getFS()); @@ -623,11 +623,12 @@ public class CloneCommandTest extends RepositoryTestCase { command.setURI(fileUri()); git2 = command.call(); addRepoToClose(git2.getRepository()); - assertTrue(git2 - .getRepository() - .getConfig() - .getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, "test", - ConfigConstants.CONFIG_KEY_REBASE, false)); + assertEquals(BranchRebaseMode.REBASE, + git2.getRepository().getConfig().getEnum( + BranchRebaseMode.values(), + ConfigConstants.CONFIG_BRANCH_SECTION, "test", + ConfigConstants.CONFIG_KEY_REBASE, + BranchRebaseMode.NONE)); userConfig.setString(ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE, @@ -639,11 +640,12 @@ public class CloneCommandTest extends RepositoryTestCase { command.setURI(fileUri()); git2 = command.call(); addRepoToClose(git2.getRepository()); - assertTrue(git2 - .getRepository() - .getConfig() - .getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, "test", - ConfigConstants.CONFIG_KEY_REBASE, false)); + assertEquals(BranchRebaseMode.REBASE, + git2.getRepository().getConfig().getEnum( + BranchRebaseMode.values(), + ConfigConstants.CONFIG_BRANCH_SECTION, "test", + ConfigConstants.CONFIG_KEY_REBASE, + BranchRebaseMode.NONE)); } 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, |