package org.dstadler.jgit.porcelain;

/*
   Copyright 2013, 2014 Dominik Stadler

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */

import java.io.IOException;
import java.util.List;

import org.dstadler.jgit.helper.CookbookHelper;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;



/**
 * Simple snippet which shows how to list all Tags
 * 
 * @author dominik.stadler at gmx.at
 */
public class ListTags {

    public static void main(String[] args) throws IOException, GitAPIException {
        Repository repository = CookbookHelper.openJGitCookbookRepository();

        List<Ref> call = new Git(repository).tagList().call();
        for (Ref ref : call) {
            System.out.println("Tag: " + ref + " " + ref.getName() + " " + ref.getObjectId().getName());
        }

        repository.close();
    }
}

@@ -762,16 +762,56 @@
 pi.Git;%0A
+import org.eclipse.jgit.api.LogCommand;%0A
 import o
@@ -850,24 +850,24 @@
 IException;%0A
-
 import org.e
@@ -927,16 +927,59 @@
 sitory;%0A
+import org.eclipse.jgit.revwalk.RevCommit;%0A
 %0A%0A%0A/**%0A 
@@ -1030,17 +1030,16 @@
  Tags%0A *
- 
 %0A * @aut
@@ -1350,16 +1350,16 @@
 call) %7B%0A
-
         
@@ -1454,16 +1454,547 @@
 Name());
+%0A%0A            // fetch all commits for this tag%0A            LogCommand log = new Git(repository).log();%0A%0A            Ref peeledRef = repository.peel(ref);%0A            if(peeledRef.getPeeledObjectId() != null) %7B%0A            %09log.add(peeledRef.getPeeledObjectId());%0A            %7D else %7B%0A            %09log.add(ref.getObjectId());%0A            %7D%0A%0A%09%09%09Iterable%3CRevCommit%3E logs = log.call();%0A%09%09%09for (RevCommit rev : logs) %7B%0A%09%09%09%09System.out.println(%22Commit: %22 + rev /* + %22, name: %22 + rev.getName() + %22, id: %22 + rev.getId().getName() */);%0A%09%09%09%7D
 %0A       

Enhance ListTags to also list commits for each tag