diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2014-08-03 07:33:28 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2014-08-03 07:33:28 -0400 |
commit | d97558fb1ccf47473fefe22b53b18a3d27438d82 (patch) | |
tree | 7d2696ef85b63f00c8beb2c7f4b37797e33b5a8d | |
parent | b397e7b6e02a3fa446f3f08aadfb97675c1af48e (diff) | |
parent | f5494c186f4fb54d13527944bd1b59ff8c291364 (diff) | |
download | jgit-d97558fb1ccf47473fefe22b53b18a3d27438d82.tar.gz jgit-d97558fb1ccf47473fefe22b53b18a3d27438d82.zip |
Merge "Add isRebase to API of BranchConfig"
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/BranchConfigTest.java | 16 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java | 14 |
2 files changed, 27 insertions, 3 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/BranchConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/BranchConfigTest.java index 63441bfe90..87bb082485 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/BranchConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/BranchConfigTest.java @@ -45,7 +45,9 @@ package org.eclipse.jgit.lib; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import org.eclipse.jgit.errors.ConfigInvalidException; import org.junit.Test; @@ -144,6 +146,20 @@ public class BranchConfigTest { branchConfig.getTrackingBranch()); } + @Test + public void isRebase() { + Config c = parse("" // + + "[branch \"undefined\"]\n" + + "[branch \"false\"]\n" + + " rebase = false\n" + + "[branch \"true\"]\n" + + " rebase = true\n"); + + assertFalse(new BranchConfig(c, "undefined").isRebase()); + assertFalse(new BranchConfig(c, "false").isRebase()); + assertTrue(new BranchConfig(c, "true").isRebase()); + } + private static Config parse(final String content) { final Config c = new Config(null); try { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java index 3a2c54485d..a62f6c3b5d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java @@ -134,9 +134,17 @@ public class BranchConfig { * @since 3.5 */ public String getMerge() { - return config.getString( - ConfigConstants.CONFIG_BRANCH_SECTION, branchName, - ConfigConstants.CONFIG_KEY_MERGE); + return config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, + branchName, ConfigConstants.CONFIG_KEY_MERGE); + } + + /** + * @return {@code true} if the branch is configured to be rebased + * @since 3.5 + */ + public boolean isRebase() { + return config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, + branchName, ConfigConstants.CONFIG_KEY_REBASE, false); } /** |