org.eclipse.jgit.api.Git.tagList()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中org.eclipse.jgit.api.Git.tagList()方法的一些代码示例,展示了Git.tagList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.tagList()方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:tagList

Git.tagList介绍

[英]Return a command object used to list tags
[中]返回用于列出标记的命令对象

代码示例

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

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());
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

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);

代码示例来源:origin: centic9/jgit-cookbook

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);
      }
    }
  }
}

代码示例来源:origin: centic9/jgit-cookbook

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);
      }
    }
  }
}

代码示例来源:origin: centic9/jgit-cookbook

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() */);
          }
        }
      }
    }
  }
}

代码示例来源:origin: centic9/jgit-cookbook

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() */);
          }
        }
      }
    }
  }
}

代码示例来源:origin: danielflower/multi-module-maven-release-plugin

@Override
public Collection<Ref> getTags() throws GitAPIException {
  return git.tagList().call();
}

代码示例来源:origin: org.apache.camel/camel-git

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);
}

代码示例来源:origin: io.fabric8.patch/patch-management

@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;
}

代码示例来源:origin: org.apereo.cas/cas-mgmt-support-version-control

/**
 * 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;
  }
}

代码示例来源:origin: jboss-fuse/fabric8

@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;
}

代码示例来源:origin: danielflower/multi-module-maven-release-plugin

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;
}

代码示例来源:origin: openl-tablets/openl-tablets

private String getVersionName(ObjectId commitId) throws GitAPIException {
  return getVersionName(git.tagList().call(), commitId);
}

代码示例来源:origin: tomasbjerre/git-changelog-lib

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;
}

代码示例来源:origin: maks/MGit

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];
}

代码示例来源:origin: sheimi/SGit

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];
}

代码示例来源:origin: com.centurylink.mdw/mdw-common

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;
}

代码示例来源:origin: org.apache.camel/camel-git

@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;
}

代码示例来源:origin: gradle.plugin.io.apioo.versioning/versioning-plugin

protected static List<Ref> getTagRefs(File projectDir) throws IOException, GitAPIException {
  Repository repository = getRepository(getRepositoryLocation(projectDir));
  Git git = new Git(repository);
  return git.tagList().call();
}

代码示例来源:origin: ModeShape/modeshape

@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);
  }
}

相关文章