private Collection<String> getTags(final Git git, final ObjectId objectId, final RevWalk finalWalk) throws GitAPIException { return git.tagList().call() .stream() .filter(tagRef -> { try { final RevCommit tagCommit = finalWalk.parseCommit(tagRef.getObjectId()); final RevCommit objectCommit = finalWalk.parseCommit(objectId); if (finalWalk.isMergedInto(objectCommit, tagCommit)) { return true; } } catch (Exception ignored) { log.debug("Failed while getTags [{}] -- ", tagRef, ignored); } return false; }) .map(tagRef -> trimFullTagName(tagRef.getName())) .collect(Collectors.toList()); }
walk.markStart(walk.parseCommit(repo.resolve("HEAD"))); List<Ref> tagRefs = Git.wrap(repo).tagList().call(); Pattern regex = Pattern.compile(matchPattern); log.info("Tag refs [{}]", tagRefs);
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (Git git = new Git(repository)) { List<Ref> refs = git.branchList().call(); for (Ref ref : refs) { System.out.println("Branch: " + ref + " " + ref.getName() + " " + ref.getObjectId().getName()); listReflog(repository, ref); } List<Ref> call = git.tagList().call(); for (Ref ref : call) { System.out.println("Tag: " + ref + " " + ref.getName() + " " + ref.getObjectId().getName()); listReflog(repository, ref); } } } }
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (Git git = new Git(repository)) { List<Ref> refs = git.branchList().call(); for (Ref ref : refs) { System.out.println("Branch: " + ref + " " + ref.getName() + " " + ref.getObjectId().getName()); listReflog(repository, ref); } List<Ref> call = git.tagList().call(); for (Ref ref : call) { System.out.println("Tag: " + ref + " " + ref.getName() + " " + ref.getObjectId().getName()); listReflog(repository, ref); } } } }
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (Git git = new Git(repository)) { List<Ref> call = git.tagList().call(); for (Ref ref : call) { System.out.println("Tag: " + ref + " " + ref.getName() + " " + ref.getObjectId().getName()); // fetch all commits for this tag LogCommand log = git.log(); Ref peeledRef = repository.getRefDatabase().peel(ref); if(peeledRef.getPeeledObjectId() != null) { log.add(peeledRef.getPeeledObjectId()); } else { log.add(ref.getObjectId()); } Iterable<RevCommit> logs = log.call(); for (RevCommit rev : logs) { System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); } } } } } }
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (Git git = new Git(repository)) { List<Ref> call = git.tagList().call(); for (Ref ref : call) { System.out.println("Tag: " + ref + " " + ref.getName() + " " + ref.getObjectId().getName()); // fetch all commits for this tag LogCommand log = git.log(); Ref peeledRef = repository.getRefDatabase().peel(ref); if(peeledRef.getPeeledObjectId() != null) { log.add(peeledRef.getPeeledObjectId()); } else { log.add(ref.getObjectId()); } Iterable<RevCommit> logs = log.call(); for (RevCommit rev : logs) { System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); } } } } } }
@Override public Collection<Ref> getTags() throws GitAPIException { return git.tagList().call(); }
protected void doShowTags(Exchange exchange, String operation) throws Exception { List<Ref> result = null; try { result = git.tagList().call(); } catch (Exception e) { LOG.error("There was an error in Git {} operation", operation); throw e; } updateExchange(exchange, result); }
@Override public boolean containsTag(Git git, String tagName) throws GitAPIException { for (Ref tag : git.tagList().call()) { if (tag.getName().startsWith("refs/tags/") && tag.getName().endsWith("/" + tagName)) { return true; } } return false; }
/** * Method returns the Ref to the commit witht the published tag. * * @return - Ref of the published commit */ public Ref getPublished() { try { val ref = git.tagList().call().get(0); return git.getRepository().peel(ref); } catch (final Exception e) { LOGGER.trace(e.getMessage(), e); return null; } }
@Override public boolean containsTag(Git git, String tagName) throws GitAPIException { for (Ref tag : git.tagList().call()) { if (tag.getName().startsWith("refs/tags/") && tag.getName().endsWith("/" + tagName)) { return true; } } return false; }
private static Ref tag(Git repo, Matcher matcher) throws GitAPIException { for (Ref ref : repo.tagList().call()) { String currentTag = ref.getName().replace("refs/tags/", ""); if (matcher.matches(currentTag)) { return ref; } } return null; }
private String getVersionName(ObjectId commitId) throws GitAPIException { return getVersionName(git.tagList().call(), commitId); }
private List<Ref> tagsBetweenFromAndTo(final ObjectId from, final ObjectId to) throws Exception { final List<Ref> tagList = this.git.tagList().call(); final List<RevCommit> icludedCommits = newArrayList(this.git.log().addRange(from, to).call()); final List<Ref> includedTags = newArrayList(); for (final Ref tag : tagList) { final ObjectId peeledTag = getPeeled(tag); if (icludedCommits.contains(peeledTag)) { includedTags.add(tag); } } return includedTags; }
public String[] getTags() { try { List<Ref> refs = getGit().tagList().call(); String[] tags = new String[refs.size()]; // convert refs/tags/[branch] -> heads/[branch] for (int i = 0; i < tags.length; ++i) { tags[i] = refs.get(i).getName(); } return tags; } catch (GitAPIException|StopTaskException e) { Timber.e(e); } return new String[0]; }
public String[] getTags() { try { List<Ref> refs = getGit().tagList().call(); String[] tags = new String[refs.size()]; // convert refs/tags/[branch] -> heads/[branch] for (int i = 0; i < tags.length; ++i) { tags[i] = refs.get(i).getName(); } return tags; } catch (GitAPIException e) { BasicFunctions.showException(e); } catch (StopTaskException e) { } return new String[0]; }
public String getCommitForTag(String tag) throws Exception { fetch(); List<Ref> tagRefs = git.tagList().call(); for (Ref tagRef : tagRefs) { if (tagRef.getName().equals("refs/tags/" + tag)) return tagRef.getObjectId().name(); } return null; }
@Override protected int poll() throws Exception { int count = 0; List<Ref> call = getGit().tagList().call(); for (Ref ref : call) { if (!tagsConsumed.contains(ref.getName())) { Exchange e = getEndpoint().createExchange(); e.getOut().setBody(ref); getProcessor().process(e); tagsConsumed.add(ref.getName()); count++; } } return count; }
protected static List<Ref> getTagRefs(File projectDir) throws IOException, GitAPIException { Repository repository = getRepository(getRepositoryLocation(projectDir)); Git git = new Git(repository); return git.tagList().call(); }
@Test public void shouldGetTags() throws Exception { // print = true; ListTagCommand command = git.tagList(); for (Ref ref : command.call()) { String fullName = ref.getName(); String name = fullName.replaceFirst("refs/tags/", ""); print(fullName + " \t--> " + name); } }