@Ignore("No unit test, depends on state of git repo") @Test public void testFindTags () throws IOException { JGitScanner jGitScanner = new JGitScanner("../.git", null); List<GitTag> tags = jGitScanner.findTags (); assertThat (tags.size(), greaterThan (0)); }
List<GitTag> findTags() throws IOException { Repository repository = getRepository(); List<GitTag> result = new LinkedList<>(); try (Git git = new Git(repository)) { List<Ref> tags = git.tagList().call(); for (Ref tagRef : tags) { String label = tagRef.getName(); RevCommit firstCommit = resolveFirstCommitForTag (git, tagRef); String objectId = ObjectId.toString(firstCommit); logger.debug ("Found Tag '{}' (name = '{}', sha = '{}')", tagRef, label, objectId); GitTag newTag = new GitTag (label, objectId); result.add (newTag); } } catch (GitAPIException e) { throw new IllegalStateException("Could not read tags from Git repository '" + path + "'", e); } finally { repository.close(); } return result; }
JGitScanner { List<GitTag> findTags() throws IOException { Repository repository = getRepository(); List<GitTag> result = new LinkedList<>(); try (Git git = new Git(repository)) { List<Ref> tags = git.tagList().call(); for (Ref tagRef : tags) { String label = tagRef.getName(); RevCommit firstCommit = resolveFirstCommitForTag (git, tagRef); String objectId = ObjectId.toString(firstCommit); logger.debug ("Found Tag '{}' (name = '{}', sha = '{}')", tagRef, label, objectId); GitTag newTag = new GitTag (label, objectId); result.add (newTag); } } catch (GitAPIException e) { throw new IllegalStateException("Could not read tags from Git repository '" + path + "'", e); } finally { repository.close(); } return result; } }
JGitScanner { List<GitTag> findTags() throws IOException { Repository repository = getRepository(); List<GitTag> result = new LinkedList<>(); try (Git git = new Git(repository)) { List<Ref> tags = git.tagList().call(); for (Ref tagRef : tags) { String label = tagRef.getName(); RevCommit firstCommit = resolveFirstCommitForTag (git, tagRef); String objectId = ObjectId.toString(firstCommit); logger.debug ("Found Tag '{}' (name = '{}', sha = '{}')", tagRef, label, objectId); GitTag newTag = new GitTag (label, objectId); result.add (newTag); } } catch (GitAPIException e) { throw new IllegalStateException("Could not read tags from Git repository '" + path + "'", e); } finally { repository.close(); } return result; } JGitScanner(final String path, String range); }
JGitScanner { List<GitTag> findTags() throws IOException { Repository repository = getRepository(); List<GitTag> result = new LinkedList<>(); try (Git git = new Git(repository)) { List<Ref> tags = git.tagList().call(); for (Ref tagRef : tags) { String label = tagRef.getName(); RevCommit firstCommit = resolveFirstCommitForTag (git, tagRef); String objectId = ObjectId.toString(firstCommit); logger.debug ("Found Tag '{}' (name = '{}', sha = '{}')", tagRef, label, objectId); GitTag newTag = new GitTag (label, objectId); result.add (newTag); } } catch (GitAPIException e) { throw new IllegalStateException("Could not read tags from Git repository '" + path + "'", e); } finally { repository.close(); } return result; } JGitScanner(final String path, String range); static void main(String[] args); }
JGitScanner { List<GitTag> findTags() throws IOException { Repository repository = getRepository(); List<GitTag> result = new LinkedList<>(); try (Git git = new Git(repository)) { List<Ref> tags = git.tagList().call(); for (Ref tagRef : tags) { String label = tagRef.getName(); RevCommit firstCommit = resolveFirstCommitForTag (git, tagRef); String objectId = ObjectId.toString(firstCommit); logger.debug ("Found Tag '{}' (name = '{}', sha = '{}')", tagRef, label, objectId); GitTag newTag = new GitTag (label, objectId); result.add (newTag); } } catch (GitAPIException e) { throw new IllegalStateException("Could not read tags from Git repository '" + path + "'", e); } finally { repository.close(); } return result; } JGitScanner(final String path, String range); static void main(String[] args);  }