Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-11-20 15:47:22 -0500
committerThomas Wolf2019-11-23 11:34:17 -0500
commit1009fc591d26f3eb824d7c42edaefa9d9799cf72 (patch)
tree4b3920e9f040b895eb21fd7164d57f20982cda93
parent89de01fb8835e9840f302a78d3f8f8b342097294 (diff)
downloadegit-1009fc591d26f3eb824d7c42edaefa9d9799cf72.tar.gz
egit-1009fc591d26f3eb824d7c42edaefa9d9799cf72.tar.xz
egit-1009fc591d26f3eb824d7c42edaefa9d9799cf72.zip
Ref filter dialog: use standard Eclipse variable syntax
Use "${git_branch}" instead of "[CURRENT-BRANCH]". Adjust the explanation and the tests accordingly. GitHistoryReffilterConfigurationDialogTest didn't work on OS X. First, the key events were not sent on the UI thread, and second, they never arrived at the cell editor. Rewrite this part to use normal setText() following the example given by the SWTBot developers.[1] [1] https://github.com/ketan/swtbot/blob/master/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableClickTest.java Bug: 553072 Change-Id: I8d092c0035b1d5cb3025552e5022a6b5ac53054f Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/GitHistoryRefFilterConfigurationDialogTest.java87
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java4
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/RefFilterHelperTest.java44
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/RefFilterHelper.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/variables/GitVariableResolver.java21
6 files changed, 76 insertions, 88 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/GitHistoryRefFilterConfigurationDialogTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/GitHistoryRefFilterConfigurationDialogTest.java
index 954013d12..6065e2027 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/GitHistoryRefFilterConfigurationDialogTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/GitHistoryRefFilterConfigurationDialogTest.java
@@ -40,10 +40,7 @@ import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTestUtils;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
@@ -103,7 +100,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilter> testFilters = new ArrayList<>();
testFilters.add(newRefFilter("HEAD", true, false));
- testFilters.add(newRefFilter("refs/**/[CURRENT-BRANCH]", true, false));
+ testFilters.add(newRefFilter("refs/**/${git_branch}", true, false));
testFilters.add(newRefFilter("refs/heads/**", true, true));
testFilters.add(newRefFilter("refs/remotes/**", true, false));
testFilters.add(newRefFilter("refs/tags/**", true, false));
@@ -152,7 +149,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilter> defaults = new ArrayList<>();
defaults.add(newRefFilter("HEAD", true, true));
- defaults.add(newRefFilter("refs/**/[CURRENT-BRANCH]", true, false));
+ defaults.add(newRefFilter("refs/**/${git_branch}", true, false));
defaults.add(newRefFilter("refs/heads/**", true, false));
defaults.add(newRefFilter("refs/remotes/**", true, false));
defaults.add(newRefFilter("refs/tags/**", true, false));
@@ -172,7 +169,9 @@ public class GitHistoryRefFilterConfigurationDialogTest
@After
public void teardown() {
myRepoViewUtil.dispose();
- display.asyncExec(dialog::close);
+ if (dialog != null) {
+ display.asyncExec(dialog::close);
+ }
}
private static class RefFilterInfo {
@@ -310,7 +309,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, true));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -330,7 +329,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, true));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, true));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -351,7 +350,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, true));
expected.add(new RefFilterInfo("refs/remotes/**", true, true));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -371,7 +370,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, false));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -392,7 +391,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, false));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -413,7 +412,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, false));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -424,48 +423,22 @@ public class GitHistoryRefFilterConfigurationDialogTest
verifyTableContentsClickOkAndVerifyResult(expected);
}
- private Event createEvent(Control control) {
- Event event = new Event();
- event.keyCode = SWT.NONE;
- event.stateMask = SWT.NONE;
- event.doit = true;
- event.widget = control;
- event.button = 1;
- return event;
- }
-
- private void keyEvent(Control control, int keyCode) {
- Event event = createEvent(control);
- event.button = 0;
- event.type = SWT.KeyDown;
- event.keyCode = keyCode;
- event.character = (char) keyCode;
-
- Display.getDefault().post(event);
-
- event.type = SWT.KeyUp;
-
- Display.getDefault().post(event);
- }
-
- private void typeTextAndEnter(String text) {
- Control c = dialog.getShell();
- for (int i = 0; i < text.length(); i++) {
- keyEvent(c, text.charAt(i));
- }
- keyEvent(c, 13);
+ private void typeTextAndApply(String text) {
+ bot.text(0).setText(text);
+ // Click somewhere else; the editor applies its value
+ bot.table().click(0, 0);
}
@Test
public void testAdd() throws Exception {
click(UIText.GitHistoryPage_filterRefDialog_button_add);
- typeTextAndEnter("added");
+ typeTextAndApply("added");
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, true));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -518,7 +491,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, true));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -539,7 +512,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, true));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -555,12 +528,12 @@ public class GitHistoryRefFilterConfigurationDialogTest
table.getTableItem(5).select();
click(UIText.GitHistoryPage_filterRefDialog_button_edit);
- typeTextAndEnter("edited");
+ typeTextAndApply("edited");
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, true));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -577,12 +550,12 @@ public class GitHistoryRefFilterConfigurationDialogTest
SWTBotTableItem item = table.getTableItem(5);
item.doubleClick();
- typeTextAndEnter("edited");
+ typeTextAndApply("edited");
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, true));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -601,7 +574,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, true));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, false));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -618,7 +591,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, false));
- expected.add(new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, true));
+ expected.add(new RefFilterInfo("refs/**/${git_branch}", true, true));
expected.add(new RefFilterInfo("refs/heads/**", true, false));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -636,7 +609,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, true));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, true));
expected.add(new RefFilterInfo("refs/remotes/**", true, true));
expected.add(new RefFilterInfo("refs/tags/**", true, true));
@@ -654,7 +627,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, true));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, false));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -671,7 +644,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
List<RefFilterInfo> expected = new ArrayList<>();
expected.add(new RefFilterInfo("HEAD", true, true));
expected.add(
- new RefFilterInfo("refs/**/[CURRENT-BRANCH]", true, false));
+ new RefFilterInfo("refs/**/${git_branch}", true, false));
expected.add(new RefFilterInfo("refs/heads/**", true, false));
expected.add(new RefFilterInfo("refs/remotes/**", true, false));
expected.add(new RefFilterInfo("refs/tags/**", true, false));
@@ -724,7 +697,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
public void testCancelAfterAdd() throws Exception {
click(UIText.GitHistoryPage_filterRefDialog_button_add);
- typeTextAndEnter("added");
+ typeTextAndApply("added");
clickCancel();
verify(refFilterHelper, Mockito.never())
@@ -737,7 +710,7 @@ public class GitHistoryRefFilterConfigurationDialogTest
table.getTableItem(5).select();
click(UIText.GitHistoryPage_filterRefDialog_button_edit);
- typeTextAndEnter("edited");
+ typeTextAndApply("edited");
clickCancel();
verify(refFilterHelper, Mockito.never())
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
index 419030677..c17ce589e 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
@@ -670,10 +670,10 @@ public class HistoryViewTest extends GitRepositoriesViewTestBase {
uncheckRefFilter(selectedRefs, "HEAD");
assertNoCommit(table);
- checkRefFilter(selectedRefs, "refs/**/[CURRENT-BRANCH]");
+ checkRefFilter(selectedRefs, "refs/**/${git_branch}");
assertCommitsAfterBase(table, "testDa", "testDb");
- uncheckRefFilter(selectedRefs, "refs/**/[CURRENT-BRANCH]");
+ uncheckRefFilter(selectedRefs, "refs/**/${git_branch}");
assertNoCommit(table);
checkRefFilter(selectedRefs, "refs/heads/**");
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/RefFilterHelperTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/RefFilterHelperTest.java
index fb99454f3..97c5971ba 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/RefFilterHelperTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/RefFilterHelperTest.java
@@ -257,7 +257,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
List<Matcher<? super RefFilter>> expected = new ArrayList<>();
expected.add(newRefFilterMatcher("HEAD", true, true));
expected.add(
- newRefFilterMatcher("refs/**/[CURRENT-BRANCH]", true, false));
+ newRefFilterMatcher("refs/**/${git_branch}", true, false));
expected.add(newRefFilterMatcher("refs/heads/**", true, false));
expected.add(newRefFilterMatcher("refs/remotes/**", true, false));
expected.add(newRefFilterMatcher("refs/tags/**", true, false));
@@ -276,7 +276,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
.thenReturn("HEAD:test");
Set<RefFilter> testSet = new HashSet<>();
testSet.add(newRefFilter("HEAD", true, false));
- testSet.add(newRefFilter("refs/**/[CURRENT-BRANCH]", true,
+ testSet.add(newRefFilter("refs/**/${git_branch}", true,
false));
testSet.add(newRefFilter("refs/heads/**", true, true));
testSet.add(newRefFilter("refs/remotes/**", true, false));
@@ -288,7 +288,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
List<Matcher<? super RefFilter>> expected = new ArrayList<>();
expected.add(newRefFilterMatcher("HEAD", true, true));
expected.add(
- newRefFilterMatcher("refs/**/[CURRENT-BRANCH]", true, false));
+ newRefFilterMatcher("refs/**/${git_branch}", true, false));
expected.add(newRefFilterMatcher("refs/heads/**", true, false));
expected.add(newRefFilterMatcher("refs/remotes/**", true, false));
expected.add(newRefFilterMatcher("refs/tags/**", true, false));
@@ -305,7 +305,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
public void testSetFilters() throws Exception {
Set<RefFilter> testSet = new HashSet<>();
testSet.add(newRefFilter("HEAD", true, false));
- testSet.add(newRefFilter("refs/**/[CURRENT-BRANCH]", true,
+ testSet.add(newRefFilter("refs/**/${git_branch}", true,
false));
testSet.add(newRefFilter("refs/heads/**", true, true));
testSet.add(newRefFilter("refs/remotes/**", true, false));
@@ -333,7 +333,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
public void testSaveSelectionStateAsLastSelectionState() throws Exception {
Set<RefFilter> testSet = new HashSet<>();
testSet.add(newRefFilter("HEAD", true, false));
- testSet.add(newRefFilter("refs/**/[CURRENT-BRANCH]", true,
+ testSet.add(newRefFilter("refs/**/${git_branch}", true,
false));
testSet.add(newRefFilter("refs/heads/**", true, true));
testSet.add(newRefFilter("refs/remotes/**", true, false));
@@ -398,7 +398,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
throws Exception {
checkMatchingRefsForSelectedRefFilters("HEAD",
Arrays.asList(ref(equalTo("HEAD"))));
- checkMatchingRefsForSelectedRefFilters("refs/**/[CURRENT-BRANCH]",
+ checkMatchingRefsForSelectedRefFilters("refs/**/${git_branch}",
Arrays.asList(ref(equalTo("refs/heads/master")),
ref(equalTo("refs/remotes/origin/master"))));
checkMatchingRefsForSelectedRefFilters("refs/heads/**",
@@ -414,7 +414,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
public void testSelectOnlyHEAD() throws Exception {
Set<RefFilter> testSet = new HashSet<>();
testSet.add(newRefFilter("HEAD", true, false));
- testSet.add(newRefFilter("refs/**/[CURRENT-BRANCH]", true,
+ testSet.add(newRefFilter("refs/**/${git_branch}", true,
false));
testSet.add(newRefFilter("refs/heads/**", true, true));
testSet.add(newRefFilter("refs/remotes/**", true, false));
@@ -426,7 +426,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
List<Matcher<? super RefFilter>> expected = new ArrayList<>();
expected.add(newRefFilterMatcher("HEAD", true, true));
expected.add(
- newRefFilterMatcher("refs/**/[CURRENT-BRANCH]", true, false));
+ newRefFilterMatcher("refs/**/${git_branch}", true, false));
expected.add(newRefFilterMatcher("refs/heads/**", true, false));
expected.add(newRefFilterMatcher("refs/remotes/**", true, false));
expected.add(newRefFilterMatcher("refs/tags/**", true, false));
@@ -443,7 +443,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
public void testIsOnlyHEADSelected() throws Exception {
Set<RefFilter> testSet1 = new HashSet<>();
testSet1.add(newRefFilter("HEAD", true, false));
- testSet1.add(newRefFilter("refs/**/[CURRENT-BRANCH]",
+ testSet1.add(newRefFilter("refs/**/${git_branch}",
true, false));
testSet1.add(newRefFilter("refs/heads/**", true, true));
testSet1.add(
@@ -458,7 +458,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
Set<RefFilter> testSet2 = new HashSet<>();
testSet2.add(newRefFilter("HEAD", true, true));
- testSet2.add(newRefFilter("refs/**/[CURRENT-BRANCH]",
+ testSet2.add(newRefFilter("refs/**/${git_branch}",
true, false));
testSet2.add(newRefFilter("refs/heads/**", true, true));
testSet2.add(
@@ -473,7 +473,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
Set<RefFilter> testSet3 = new HashSet<>();
testSet3.add(newRefFilter("HEAD", true, true));
- testSet3.add(newRefFilter("refs/**/[CURRENT-BRANCH]",
+ testSet3.add(newRefFilter("refs/**/${git_branch}",
true, false));
testSet3.add(newRefFilter("refs/heads/**", true, false));
testSet3.add(
@@ -492,7 +492,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
public void testSelectOnlyCurrentBranch() throws Exception {
Set<RefFilter> testSet = new HashSet<>();
testSet.add(newRefFilter("HEAD", true, false));
- testSet.add(newRefFilter("refs/**/[CURRENT-BRANCH]", true,
+ testSet.add(newRefFilter("refs/**/${git_branch}", true,
false));
testSet.add(newRefFilter("refs/heads/**", true, true));
testSet.add(newRefFilter("refs/remotes/**", true, false));
@@ -504,7 +504,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
List<Matcher<? super RefFilter>> expected = new ArrayList<>();
expected.add(newRefFilterMatcher("HEAD", true, false));
expected.add(
- newRefFilterMatcher("refs/**/[CURRENT-BRANCH]", true, true));
+ newRefFilterMatcher("refs/**/${git_branch}", true, true));
expected.add(newRefFilterMatcher("refs/heads/**", true, false));
expected.add(newRefFilterMatcher("refs/remotes/**", true, false));
expected.add(newRefFilterMatcher("refs/tags/**", true, false));
@@ -521,7 +521,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
public void testIsOnlyCurrentBranchSelected() throws Exception {
Set<RefFilter> testSet1 = new HashSet<>();
testSet1.add(newRefFilter("HEAD", true, false));
- testSet1.add(newRefFilter("refs/**/[CURRENT-BRANCH]",
+ testSet1.add(newRefFilter("refs/**/${git_branch}",
true, false));
testSet1.add(newRefFilter("refs/heads/**", true, true));
testSet1.add(
@@ -536,7 +536,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
Set<RefFilter> testSet2 = new HashSet<>();
testSet2.add(newRefFilter("HEAD", true, false));
- testSet2.add(newRefFilter("refs/**/[CURRENT-BRANCH]",
+ testSet2.add(newRefFilter("refs/**/${git_branch}",
true, true));
testSet2.add(newRefFilter("refs/heads/**", true, true));
testSet2.add(
@@ -551,7 +551,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
Set<RefFilter> testSet3 = new HashSet<>();
testSet3.add(newRefFilter("HEAD", true, false));
- testSet3.add(newRefFilter("refs/**/[CURRENT-BRANCH]",
+ testSet3.add(newRefFilter("refs/**/${git_branch}",
true, true));
testSet3.add(newRefFilter("refs/heads/**", true, false));
testSet3.add(
@@ -570,7 +570,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
public void testSelectExactlyAllBranchesAndTags() throws Exception {
Set<RefFilter> testSet = new HashSet<>();
testSet.add(newRefFilter("HEAD", true, false));
- testSet.add(newRefFilter("refs/**/[CURRENT-BRANCH]", true,
+ testSet.add(newRefFilter("refs/**/${git_branch}", true,
false));
testSet.add(newRefFilter("refs/heads/**", true, true));
testSet.add(newRefFilter("refs/remotes/**", true, false));
@@ -582,7 +582,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
List<Matcher<? super RefFilter>> expected = new ArrayList<>();
expected.add(newRefFilterMatcher("HEAD", true, true));
expected.add(
- newRefFilterMatcher("refs/**/[CURRENT-BRANCH]", true, false));
+ newRefFilterMatcher("refs/**/${git_branch}", true, false));
expected.add(newRefFilterMatcher("refs/heads/**", true, true));
expected.add(newRefFilterMatcher("refs/remotes/**", true, true));
expected.add(newRefFilterMatcher("refs/tags/**", true, true));
@@ -599,7 +599,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
public void testIsExactlyAllBranchesAndTagsSelected() throws Exception {
Set<RefFilter> testSet1 = new HashSet<>();
testSet1.add(newRefFilter("HEAD", true, false));
- testSet1.add(newRefFilter("refs/**/[CURRENT-BRANCH]",
+ testSet1.add(newRefFilter("refs/**/${git_branch}",
true, false));
testSet1.add(newRefFilter("refs/heads/**", true, true));
testSet1.add(
@@ -614,7 +614,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
Set<RefFilter> testSet2 = new HashSet<>();
testSet2.add(newRefFilter("HEAD", true, true));
- testSet2.add(newRefFilter("refs/**/[CURRENT-BRANCH]",
+ testSet2.add(newRefFilter("refs/**/${git_branch}",
true, false));
testSet2.add(newRefFilter("refs/heads/**", true, true));
testSet2.add(newRefFilter("refs/remotes/**", true, true));
@@ -628,7 +628,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
Set<RefFilter> testSet3 = new HashSet<>();
testSet3.add(newRefFilter("HEAD", true, true));
- testSet3.add(newRefFilter("refs/**/[CURRENT-BRANCH]",
+ testSet3.add(newRefFilter("refs/**/${git_branch}",
true, false));
testSet3.add(newRefFilter("refs/heads/**", true, true));
testSet3.add(newRefFilter("refs/remotes/**", true, true));
@@ -655,7 +655,7 @@ public class RefFilterHelperTest extends LocalRepositoryTestCase {
List<Matcher<? super RefFilter>> expected = new ArrayList<>();
expected.add(newRefFilterMatcher("HEAD", true, true));
expected.add(
- newRefFilterMatcher("refs/**/[CURRENT-BRANCH]", true, false));
+ newRefFilterMatcher("refs/**/${git_branch}", true, false));
expected.add(newRefFilterMatcher("refs/heads/**", true, false));
expected.add(newRefFilterMatcher("refs/remotes/**", true, false));
expected.add(newRefFilterMatcher("refs/tags/**", true, false));
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/RefFilterHelper.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/RefFilterHelper.java
index 89414bf3d..913178dac 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/RefFilterHelper.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/RefFilterHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2019, Tim Neumann <Tim.Neumann@advantest.com>
+ * Copyright (C) 2019, Tim Neumann <Tim.Neumann@advantest.com> and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -26,6 +26,7 @@ import org.apache.tools.ant.types.selectors.TokenizedPath;
import org.apache.tools.ant.types.selectors.TokenizedPattern;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
+import org.eclipse.egit.ui.internal.variables.GitVariableResolver;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jgit.annotations.NonNull;
@@ -44,7 +45,8 @@ public class RefFilterHelper {
private static final String REF_SEPARATOR = ":"; //$NON-NLS-1$
- private static final String MACRO_CURRENT_BRANCH = "[CURRENT-BRANCH]"; //$NON-NLS-1$
+ private static final String MACRO_CURRENT_BRANCH = "${" //$NON-NLS-1$
+ + GitVariableResolver.GIT_BRANCH + '}';
private static final String DEFAULT_SELECTED_REFS = Constants.HEAD;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index e130691b7..c3ba5316f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -249,7 +249,7 @@ GitHistoryPage_configureFilters=Ref F&ilters...
GitHistoryPage_filterRefDialog_dialogMessage=Define which refs to include in the git history.
GitHistoryPage_filterRefDialog_dialogTitle=Configure Ref Filters
GitHistoryPage_filterRefDialog_filtersCompositeLabel=Filters
-GitHistoryPage_filterRefDialog_patternExplanation=Filters are treated as path filters ('?', '*' and '**' are valid wildcards). Valid macros are "[CURRENT-BRANCH]", which will be replaced by the current branch name.
+GitHistoryPage_filterRefDialog_patternExplanation=Filters are treated as path filters ('?', '*' and '**' are valid wildcards). "${git_branch}" is a macro that will be replaced by the short name of the currently checked-out branch.
GitHistoryPage_filterRefDialog_button_add=Add
GitHistoryPage_filterRefDialog_button_remove=Remove
GitHistoryPage_filterRefDialog_button_edit=Edit
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/variables/GitVariableResolver.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/variables/GitVariableResolver.java
index a78a5e671..dfae91c3c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/variables/GitVariableResolver.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/variables/GitVariableResolver.java
@@ -46,10 +46,23 @@ import org.eclipse.ui.PlatformUI;
*/
public class GitVariableResolver implements IDynamicVariableResolver {
- private static final String GIT_REPO_RELATIVE_PATH = "git_repo_relative_path"; //$NON-NLS-1$
- private static final String GIT_DIR = "git_dir"; //$NON-NLS-1$
- private static final String GIT_WORK_TREE = "git_work_tree"; //$NON-NLS-1$
- private static final String GIT_BRANCH = "git_branch"; //$NON-NLS-1$
+ /** Resolves to the repo-relative path of the argument. */
+ public static final String GIT_REPO_RELATIVE_PATH = "git_repo_relative_path"; //$NON-NLS-1$
+
+ /** Resolves to the .git directory of the repository of the argument. */
+ public static final String GIT_DIR = "git_dir"; //$NON-NLS-1$
+
+ /**
+ * Resolves to the working tree root directory of the repository of the
+ * argument.
+ */
+ public static final String GIT_WORK_TREE = "git_work_tree"; //$NON-NLS-1$
+
+ /**
+ * Resolves to the short name of the currently checked-out branch in the
+ * repository of the argument.
+ */
+ public static final String GIT_BRANCH = "git_branch"; //$NON-NLS-1$
@Override
public String resolveValue(IDynamicVariable variable, String argument)

Back to the top