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

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

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

Git.wrap介绍

[英]Wrap repository
[中]包装存储库

代码示例

代码示例来源:origin: oracle/helidon

private void pull() throws GitAPIException {
  Git git = recordGit(Git.wrap(repository));
  PullCommand pull = git.pull()
      .setRebase(true);
  PullResult result = pull.call();
  if (!result.isSuccessful()) {
    LOGGER.log(Level.WARNING, () -> String.format("Cannot pull from git '%s', branch '%s'", uri.toASCIIString(), branch));
    if (LOGGER.isLoggable(Level.FINEST)) {
      Status status = git.status().call();
      LOGGER.finest(() -> "git status cleanliness: " + status.isClean());
      if (!status.isClean()) {
        LOGGER.finest(() -> "git status uncommitted changes: " + status.getUncommittedChanges());
        LOGGER.finest(() -> "git status untracked: " + status.getUntracked());
      }
    }
  } else {
    LOGGER.fine("Pull was successful.");
  }
  LOGGER.finest(() -> "git rebase result: " + result.getRebaseResult().getStatus().name());
  LOGGER.finest(() -> "git fetch result: " + result.getFetchResult().getMessages());
}

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

public Collection<String> getTags(Repository repo, final ObjectId objectId) throws GitAPIException {
 try (Git git = Git.wrap(repo)) {
  try (RevWalk walk = new RevWalk(repo)) {
   Collection<String> tags = getTags(git, objectId, walk);
   walk.dispose();
   return tags;
  }
 }
}

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

public static boolean isRepositoryInDirtyState(Repository repo) throws GitAPIException {
  Git git = Git.wrap(repo);
  Status status = git.status().call();

  // Git describe doesn't mind about untracked files when checking if
  // repo is dirty. JGit does this, so we cannot use the isClean method
  // to get the same behaviour. Instead check dirty state without
  // status.getUntracked().isEmpty()
  boolean isDirty = !(status.getAdded().isEmpty()
    && status.getChanged().isEmpty()
    && status.getRemoved().isEmpty()
    && status.getMissing().isEmpty()
    && status.getModified().isEmpty()
    && status.getConflicting().isEmpty());

  return isDirty;
 }
}

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

private void fetch() {
 FetchCommand fetchCommand = Git.wrap(git).fetch();
 try {
  fetchCommand.setThin(true).call();
 } catch (Exception e) {
  log.error("Failed to perform fetch", e);
 }
}

代码示例来源: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: org.eclipse.jgit/org.eclipse.jgit

private void resetSoftToParent() throws IOException,
    GitAPIException, CheckoutConflictException {
  Ref ref = repo.exactRef(Constants.ORIG_HEAD);
  ObjectId orig_head = ref == null ? null : ref.getObjectId();
  try (Git git = Git.wrap(repo)) {
    // we have already committed the cherry-picked commit.
    // what we need is to have changes introduced by this
    // commit to be on the index
    // resetting is a workaround
    git.reset().setMode(ResetType.SOFT)
        .setRef("HEAD~1").call(); //$NON-NLS-1$
  } finally {
    // set ORIG_HEAD back to where we started because soft
    // reset moved it
    repo.writeOrigHead(orig_head);
  }
}

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

private void autoStash() throws GitAPIException, IOException {
  if (repo.getConfig().getBoolean(ConfigConstants.CONFIG_REBASE_SECTION,
      ConfigConstants.CONFIG_KEY_AUTOSTASH, false)) {
    String message = MessageFormat.format(
            AUTOSTASH_MSG,
            Repository
                .shortenRefName(getHeadName(getHead())));
    RevCommit stashCommit = Git.wrap(repo).stashCreate().setRef(null)
        .setWorkingDirectoryMessage(
            message)
        .call();
    if (stashCommit != null) {
      FileUtils.mkdir(rebaseState.getDir());
      rebaseState.createFile(AUTOSTASH, stashCommit.getName());
    }
  }
}

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

private boolean autoStashApply() throws IOException, GitAPIException {
  boolean conflicts = false;
  if (rebaseState.getFile(AUTOSTASH).exists()) {
    String stash = rebaseState.readFile(AUTOSTASH);
    try (Git git = Git.wrap(repo)) {
      git.stashApply().setStashRef(stash)
          .ignoreRepositoryState(true).setStrategy(strategy)
          .call();
    } catch (StashApplyFailureException e) {
      conflicts = true;
      try (RevWalk rw = new RevWalk(repo)) {
        ObjectId stashId = repo.resolve(stash);
        RevCommit commit = rw.parseCommit(stashId);
        updateStashRef(commit, commit.getAuthorIdent(),
            commit.getShortMessage());
      }
    }
  }
  return conflicts;
}

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

fetchCallback.fetchingSubmodule(generator.getPath());
FetchCommand fetchCommand = Git.wrap(repository).fetch();
if (monitor != null) {
  fetchCommand.setProgressMonitor(monitor);

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

walk.parseCommit(repo.resolve(Constants.HEAD)),
      upstreamCommit)) {
org.eclipse.jgit.api.Status status = Git.wrap(repo)
    .status().setIgnoreSubmodules(IgnoreSubmoduleMode.ALL).call();
if (status.hasUncommittedChanges()) {

代码示例来源:origin: qoomon/maven-git-versioning-extension

public static Status getStatus(Repository repository) {
  try {
    return Git.wrap(repository).status().call();
  } catch (GitAPIException e) {
    throw new RuntimeException(e);
  }
}

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

Status status = Git.wrap(submoduleRepo).status().call();
return status.isClean() ? SubmoduleDeinitStatus.SUCCESS
    : SubmoduleDeinitStatus.DIRTY;

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

private Git gitRepo(Project project) {
  try {
    File gitDir = getRootGitDir(project.getProjectDir());
    return Git.wrap(new FileRepository(gitDir));
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.arquillian.smart.testing/git-rules

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
  throws IOException, ServletException {
  chain.doFilter(request, response);
  try {
    for (final LazilyLoadedRepository repository : repositories) {
      Git.wrap(repository.get()).reset().setMode(HARD).call();
    }
  } catch (GitAPIException e) {
    throw new ServletException(e);
  }
}

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

public Collection<String> getTags(Repository repo, final ObjectId objectId) throws GitAPIException {
 try (Git git = Git.wrap(repo)) {
  try (RevWalk walk = new RevWalk(repo)) {
   Collection<String> tags = getTags(git, objectId, walk);
   walk.dispose();
   return tags;
  }
 }
}

代码示例来源:origin: io.fabric8/gitective-core

@Override
public CommitFilter setRepository(final Repository repository) {
  super.setRepository(repository);
  if (repository != null) {
    show = Git.wrap(repository).notesShow();
    noteRefs = getNoteRefs(repository);
  } else {
    show = null;
    noteRefs = null;
  }
  return this;
}

代码示例来源:origin: io.fabric8/gitective-core

@Override
public CommitFilter setRepository(final Repository repository) {
  super.setRepository(repository);
  if (repository != null) {
    show = Git.wrap(repository).notesShow();
    noteRefs = getNoteRefs(repository);
  } else {
    show = null;
    noteRefs = null;
  }
  return this;
}

代码示例来源:origin: org.arquillian.smart.testing/git-rules

private void checkoutAllBranches(Repository repository) throws GitAPIException {
  final Git git = Git.wrap(repository);
  for (final Ref ref : git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call()) {
    final String refName = ref.getName();
    final String branchName = refName.substring(refName.lastIndexOf('/') + 1);
    try {
      git.checkout().setCreateBranch(true).setName(branchName).setStartPoint("origin/" + branchName).call();
    } catch (RefAlreadyExistsException e) {
      LOGGER.warning("Already exists, so ignoring " + e.getMessage());
    }
  }
}

代码示例来源:origin: org.uberfire/uberfire-nio2-jgit

private Ref branch(Git origin, String source, String target) throws Exception {
  final Repository repo = origin.getRepository();
  return org.eclipse.jgit.api.Git.wrap(repo)
                  .branchCreate()
                  .setName(target)
                  .setStartPoint(source)
                  .call();
}

代码示例来源:origin: kiegroup/appformer

private Ref branch(Git origin, String source, String target) throws Exception {
  final Repository repo = origin.getRepository();
  return org.eclipse.jgit.api.Git.wrap(repo)
                  .branchCreate()
                  .setName(target)
                  .setStartPoint(source)
                  .call();
}

相关文章