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

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

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

Git.describe介绍

[英]Return a command object to come up with a short name that describes a commit in terms of the nearest git tag.
[中]返回一个command对象,用一个简短的名称,用最近的git标记来描述提交。

代码示例

代码示例来源:origin: gradle.plugin.com.palantir.gradle.gitversion/gradle-git-version

private boolean isRepoEmpty() {
  // back-compat: the JGit "describe" command throws an exception in repositories with no commits, so call it
  // first to preserve this behavior in cases where this call would fail but native "git" call does not.
  try {
    git.describe().call();
    return false;
  } catch (Exception ignored) {
    return true;
  }
}

代码示例来源:origin: gradle.plugin.com.xenoterracide.gradle/pluginbundle

@Override
  public void apply( Project project ) {
    try {
      Repository repo = new FileRepositoryBuilder()
          .readEnvironment()
          .findGitDir( project.getProjectDir() )
          .build();

      Git git = new Git( repo );
      Optional.ofNullable( git.describe().setMatch( "v[0-9].[0-9]*.[0-9]*" ).call() )
          .map( v -> v.substring( 1 ) )
          .ifPresent( project::setVersion );
    }
    catch ( IOException | InvalidPatternException | GitAPIException e ) {
      log.error( "", e );
    }
  }
}

代码示例来源:origin: gradle.plugin.com.xenoterracide.gradle/gradle-plugin-bundle

@Nullable
public String describe() throws InvalidPatternException, GitAPIException,
    IOException {
  String version = git.describe().setMatch( VERSION_GLOB ).call();
  if ( version == null ) {
    Ref mostRecentTag = findMostRecentTag();
    if ( mostRecentTag != null ) {
      String vtag = StringUtils.removeStart( mostRecentTag.getName(), TAG_PREFIX );
      ObjectId head = getRepo().resolve( "HEAD" );
      long commitCount = countCommits( mostRecentTag.getPeeledObjectId(), head.toObjectId() );
      version = String.join( "-", vtag, String.valueOf( commitCount ),
                  'g' + head.name().substring( 0, 7 ), "SNAPSHOT"
      );
    }
  }
  return version;
}

代码示例来源:origin: gradle.plugin.com.xenoterracide/gradle-plugin-semver

public String describe() throws InvalidPatternException, GitAPIException,
    IOException {
  String version = git.describe().setMatch( VERSION_GLOB ).call();
  if ( version == null ) {
    Ref mostRecentTag = findMostRecentTag();
    if ( mostRecentTag != null ) {
      String vtag = StringUtils.removeStart( mostRecentTag.getName(), TAG_PREFIX );
      ObjectId head = getRepo().resolve( "HEAD" );
      long commitCount = countCommits( mostRecentTag.getPeeledObjectId(), head.toObjectId() );
      version = String.join( "-", vtag, String.valueOf( commitCount ),
          'g' + head.name().substring( 0, 7 ), "SNAPSHOT"
      );
    }
  }
  return version;
}

代码示例来源:origin: gradle.plugin.com.xenoterracide/gradle-semver

String describe() throws InvalidPatternException, GitAPIException,
    IOException {
  String version = git.describe().setMatch( VERSION_GLOB ).call();
  if ( version == null ) {
    Ref mostRecentTag = findMostRecentTag();
    if ( mostRecentTag != null ) {
      String vtag = StringUtils.removeStart( mostRecentTag.getName(), TAG_PREFIX );
      ObjectId head = getRepo().resolve( "HEAD" );
      long commitCount = countCommits( mostRecentTag.getPeeledObjectId(), head.toObjectId() );
      version = String.join( "-", vtag, String.valueOf( commitCount ),
          'g' + head.name().substring( 0, 7 ), "SNAPSHOT"
      );
    }
  }
  return version;
}

代码示例来源:origin: gradle.plugin.br.com.sabium/gradle-bump

String getLatestReleaseTag(final String releaseTagPattern) throws IOException, GitAPIException {
  final Pattern tagPattern = Pattern.compile(releaseTagPattern);
  final FileRepositoryBuilder builder = new FileRepositoryBuilder();
  final Repository repository = builder.setWorkTree(new File(gitDir)).findGitDir().build();
  final RevWalk walk = new RevWalk(repository);
  walk.markStart(walk.parseCommit(repository.resolve("HEAD")));
  final String tag = new Git(repository).describe().call();
  walk.reset();
  final Matcher releaseTagMatcher = tagPattern.matcher(tag);
  repository.close();
  return releaseTagMatcher.matches() ? tag : null;
}

代码示例来源:origin: com.dell.doradus/doradus-server

instance().m_logger.info("Remote.origin.url: {}", url);
if (!Utils.isEmpty(url) && url.contains("dell-oss/Doradus.git")) {
  DescribeCommand cmd = git.describe();
  version = cmd.call();
  instance().m_logger.info("Doradus version found from git repo: {}", version);

代码示例来源:origin: QSFT/Doradus

instance().m_logger.info("Remote.origin.url: {}", url);
if (!Utils.isEmpty(url) && url.contains("dell-oss/Doradus.git")) {
  DescribeCommand cmd = git.describe();
  version = cmd.call();
  instance().m_logger.info("Doradus version found from git repo: {}", version);

代码示例来源:origin: com.madgag/org.eclipse.jgit.pgm

@Override
protected void run() throws Exception {
  DescribeCommand cmd = new Git(db).describe();
  if (tree != null)
    cmd.setTarget(tree);
  String result = null;
  try {
    result = cmd.call();
  } catch (RefNotFoundException e) {
    throw die(CLIText.get().noNamesFound, e);
  }
  if (result == null)
    throw die(CLIText.get().noNamesFound);
  outw.println(result);
}

代码示例来源:origin: bsorrentino/maven-confluence-plugin

final String lastTagName = git.describe().call();
from = repository.resolve("refs/tags/" + lastTagName);

相关文章