Merge "Refspec: loosen restrictions on wildcard "*""
This commit is contained in:
commit
7c5b2761ed
|
@ -340,6 +340,41 @@ public void testWildcardInMiddleOfDestionation() {
|
||||||
assertEquals("refs/heads/foo", c.getSource());
|
assertEquals("refs/heads/foo", c.getSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWildcardAfterText1() {
|
||||||
|
RefSpec a = new RefSpec("refs/heads/*/for-linus:refs/remotes/mine/*-blah");
|
||||||
|
assertTrue(a.isWildcard());
|
||||||
|
assertTrue(a.matchDestination("refs/remotes/mine/x-blah"));
|
||||||
|
assertTrue(a.matchDestination("refs/remotes/mine/foo-blah"));
|
||||||
|
assertTrue(a.matchDestination("refs/remotes/mine/foo/x-blah"));
|
||||||
|
assertFalse(a.matchDestination("refs/remotes/origin/foo/x-blah"));
|
||||||
|
|
||||||
|
RefSpec b = a.expandFromSource("refs/heads/foo/for-linus");
|
||||||
|
assertEquals("refs/remotes/mine/foo-blah", b.getDestination());
|
||||||
|
RefSpec c = a.expandFromDestination("refs/remotes/mine/foo-blah");
|
||||||
|
assertEquals("refs/heads/foo/for-linus", c.getSource());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWildcardAfterText2() {
|
||||||
|
RefSpec a = new RefSpec("refs/heads*/for-linus:refs/remotes/mine/*");
|
||||||
|
assertTrue(a.isWildcard());
|
||||||
|
assertTrue(a.matchSource("refs/headsx/for-linus"));
|
||||||
|
assertTrue(a.matchSource("refs/headsfoo/for-linus"));
|
||||||
|
assertTrue(a.matchSource("refs/headsx/foo/for-linus"));
|
||||||
|
assertFalse(a.matchSource("refs/headx/for-linus"));
|
||||||
|
|
||||||
|
RefSpec b = a.expandFromSource("refs/headsx/for-linus");
|
||||||
|
assertEquals("refs/remotes/mine/x", b.getDestination());
|
||||||
|
RefSpec c = a.expandFromDestination("refs/remotes/mine/x");
|
||||||
|
assertEquals("refs/headsx/for-linus", c.getSource());
|
||||||
|
|
||||||
|
RefSpec d = a.expandFromSource("refs/headsx/foo/for-linus");
|
||||||
|
assertEquals("refs/remotes/mine/x/foo", d.getDestination());
|
||||||
|
RefSpec e = a.expandFromDestination("refs/remotes/mine/x/foo");
|
||||||
|
assertEquals("refs/headsx/foo/for-linus", e.getSource());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWildcardMirror() {
|
public void testWildcardMirror() {
|
||||||
RefSpec a = new RefSpec("*:*");
|
RefSpec a = new RefSpec("*:*");
|
||||||
|
@ -403,21 +438,6 @@ public void invalidWhenMoreThanOneWildcardInDestination() {
|
||||||
assertNotNull(new RefSpec("refs/heads/*:refs/heads/*/*"));
|
assertNotNull(new RefSpec("refs/heads/*:refs/heads/*/*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void invalidWhenWildcardAfterText() {
|
|
||||||
assertNotNull(new RefSpec("refs/heads/wrong*:refs/heads/right/*"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void invalidWhenWildcardBeforeText() {
|
|
||||||
assertNotNull(new RefSpec("*wrong:right/*"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void invalidWhenWildcardBeforeTextAtEnd() {
|
|
||||||
assertNotNull(new RefSpec("refs/heads/*wrong:right/*"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void invalidSourceDoubleSlashes() {
|
public void invalidSourceDoubleSlashes() {
|
||||||
assertNotNull(new RefSpec("refs/heads//wrong"));
|
assertNotNull(new RefSpec("refs/heads//wrong"));
|
||||||
|
|
|
@ -457,10 +457,6 @@ private static boolean isValid(final String s) {
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
if (s.indexOf('*', i + 1) > i)
|
if (s.indexOf('*', i + 1) > i)
|
||||||
return false;
|
return false;
|
||||||
if (i > 0 && s.charAt(i - 1) != '/')
|
|
||||||
return false;
|
|
||||||
if (i < s.length() - 1 && s.charAt(i + 1) != '/')
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue