]> source.dussan.org Git - jgit.git/commitdiff
[pgm] Add option --tags for ls-remote 84/37384/3
authorMatthias Sohn <matthias.sohn@sap.com>
Sun, 23 Nov 2014 23:52:45 +0000 (00:52 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 16 Dec 2014 14:29:08 +0000 (15:29 +0100)
Bug: 444072
Change-Id: I52b470924609fc201e078d9d232aad257506728d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/LsRemoteTest.java
org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java

index f03edb06932a5e72c8bad18b5694d78212f58075..ba6b771de5c8f439e76469e06f751f8ad88a579f 100644 (file)
@@ -104,4 +104,35 @@ public class LsRemoteTest extends CLIRepositoryTestCase {
                                "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/heads/test",
                                "" }, result.toArray());
        }
+
+       @Test
+       public void testLsRemoteTags() throws Exception {
+               final List<String> result = CLIGitCommand.execute(
+                               "git ls-remote --tags " + db.getDirectory(), db);
+               assertArrayEquals(new String[] {
+                               "efc02078d83a5226986ae917323acec7e1e8b7cb       refs/tags/tag1",
+                               "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/tags/tag1^{}",
+                               "4e4b837e0fd4ba83c003678b03592dc1509a4115       refs/tags/tag2",
+                               "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/tags/tag2^{}",
+                               "489384bf8ace47522fe32093d2ceb85b65a6cbb1       refs/tags/tag3",
+                               "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/tags/tag3^{}",
+                               "" }, result.toArray());
+       }
+
+       @Test
+       public void testLsRemoteHeadsTags() throws Exception {
+               final List<String> result = CLIGitCommand.execute(
+                               "git ls-remote --heads --tags " + db.getDirectory(), db);
+               assertArrayEquals(new String[] {
+                               "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/heads/master",
+                               "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/heads/test",
+                               "efc02078d83a5226986ae917323acec7e1e8b7cb       refs/tags/tag1",
+                               "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/tags/tag1^{}",
+                               "4e4b837e0fd4ba83c003678b03592dc1509a4115       refs/tags/tag2",
+                               "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/tags/tag2^{}",
+                               "489384bf8ace47522fe32093d2ceb85b65a6cbb1       refs/tags/tag3",
+                               "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/tags/tag3^{}",
+                               "" }, result.toArray());
+       }
+
 }
index 52a21f72165cd6c044d91b0add39a837f9992c1d..7ed77ee04a3e8c37d995215398e540c6c575a676 100644 (file)
@@ -204,6 +204,7 @@ usage_Glog=View commit history as a graph
 usage_IndexPack=Build pack index file for an existing packed archive
 usage_LsRemote=List references in a remote repository
 usage_lsRemoteHeads=Show only refs starting with refs/heads
+usage_lsRemoteTags=Show only refs starting with refs/tags
 usage_LsTree=List the contents of a tree object
 usage_MakeCacheTree=Show the current cache tree structure
 usage_MergeBase=Find as good common ancestors as possible for a merge
index 096d8528d4b7c1025da2dce76704c576920c94d0..6262ad2469b69c955bf1c5885cee2a8a21a68c08 100644 (file)
@@ -61,6 +61,9 @@ class LsRemote extends TextBuiltin {
        @Option(name = "--heads", usage = "usage_lsRemoteHeads")
        private boolean heads;
 
+       @Option(name = "--tags", usage = "usage_lsRemoteTags", aliases = { "-t" })
+       private boolean tags;
+
        @Option(name = "--timeout", metaVar = "metaVar_service", usage = "usage_abortConnectionIfNoActivity")
        int timeout = -1;
 
@@ -70,7 +73,7 @@ class LsRemote extends TextBuiltin {
        @Override
        protected void run() throws Exception {
                LsRemoteCommand command = Git.lsRemoteRepository().setRemote(remote)
-                               .setTimeout(timeout).setHeads(heads);
+                               .setTimeout(timeout).setHeads(heads).setTags(tags);
                TreeSet<Ref> refs = new TreeSet<Ref>(new Comparator<Ref>() {
 
                        public int compare(Ref r1, Ref r2) {