diff options
author | Stefan Beller <sbeller@google.com> | 2016-07-22 11:39:50 -0700 |
---|---|---|
committer | Stefan Beller <sbeller@google.com> | 2016-07-25 10:10:06 -0700 |
commit | a2d3c376a682b540ecd87fe3ff2ffebc1766f938 (patch) | |
tree | 51745bde6340f646d027dd5a9559560bea87d7a3 /org.eclipse.jgit.test/tst | |
parent | 1556ca740b75661a2670ddcb581dafced3010bae (diff) | |
download | jgit-a2d3c376a682b540ecd87fe3ff2ffebc1766f938.tar.gz jgit-a2d3c376a682b540ecd87fe3ff2ffebc1766f938.zip |
RefSpecs: allow construction of weird wildcarded RefSpecs
Gerrit's superproject subscription feature uses RefSpecs to formalize
the ACLs of when the superproject subscription feature is allowed.
As this is a slightly different use case than describing a local/remote
pair of refs, we need to be more permissive. Specifically we want to allow:
refs/heads/*
refs/heads/*:refs/heads/master
refs/heads/master:refs/heads/*
Introduce a new constructor, that allows constructing these RefSpecs.
Change-Id: I46c0bea9d876e61eb2c8d50f404b905792bc72b3
Signed-off-by: Stefan Beller <sbeller@google.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefSpecTest.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefSpecTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefSpecTest.java index b14b0b3347..c9e44e768f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefSpecTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefSpecTest.java @@ -55,6 +55,7 @@ import static org.junit.Assert.assertTrue; import org.eclipse.jgit.lib.ObjectIdRef; import org.eclipse.jgit.lib.Ref; +import org.eclipse.jgit.transport.RefSpec.WildcardMode; import org.junit.Test; public class RefSpecTest { @@ -474,4 +475,28 @@ public class RefSpecTest { RefSpec a = new RefSpec("refs/heads/*:refs/remotes/origin/*"); a.setDestination("refs/remotes/origin/*/*"); } + + @Test + public void sourceOnlywithWildcard() { + RefSpec a = new RefSpec("refs/heads/*", + WildcardMode.ALLOW_MISMATCH); + assertTrue(a.matchSource("refs/heads/master")); + assertNull(a.getDestination()); + } + + @Test + public void destinationWithWildcard() { + RefSpec a = new RefSpec("refs/heads/master:refs/heads/*", + WildcardMode.ALLOW_MISMATCH); + assertTrue(a.matchSource("refs/heads/master")); + assertTrue(a.matchDestination("refs/heads/master")); + assertTrue(a.matchDestination("refs/heads/foo")); + } + + @Test + public void onlyWildCard() { + RefSpec a = new RefSpec("*", WildcardMode.ALLOW_MISMATCH); + assertTrue(a.matchSource("refs/heads/master")); + assertNull(a.getDestination()); + } } |