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

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

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

Git.stashList介绍

[英]Return a command object used to list stashed commits
[中]返回用于列出隐藏提交的命令对象

代码示例

代码示例来源:origin: jphp-group/jphp

@Signature
public Memory stashList() throws GitAPIException {
  StashListCommand command = getWrappedObject().stashList();
  return GitUtils.valueOfRevCommits(command.call());
}

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

Collection<RevCommit> stashes = git.stashList().call();
for(RevCommit rev : stashes) {
  System.out.println("Found stash: " + rev + ": " + rev.getFullMessage());

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

Collection<RevCommit> stashes = git.stashList().call();
for(RevCommit rev : stashes) {
  System.out.println("Found stash: " + rev + ": " + rev.getFullMessage());

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

private Collection<String> applyStashIfNeeded() throws GitAPIException {
  if (!git.stashList().call().isEmpty()) {
    try {
      git.stashApply().call();
    } catch (final Exception e) {
      val conflicts = git.status().call().getConflicting();
      git.close();
      return conflicts;
    }
  }
  return new HashSet<>();
}

代码示例来源:origin: alien4cloud/alien4cloud

public static void dropStash(Path repositoryDirectory, String stashId){
  Git git = null;
  try {
    git = Git.open(repositoryDirectory.toFile());
    int stashIndex = 0;
    Collection<RevCommit> stashes = git.stashList().call();
    for (RevCommit stash : stashes) {
      if (stash.getFullMessage().equals(stashId)) {
        git.stashDrop().setStashRef(stashIndex).call();
        log.debug("Stash <" + stashId + ">  has been dropped on <" + repositoryDirectory + ">");
      }
      stashIndex++;
    }
  } catch (IOException | GitAPIException e) {
    throw new GitException("Failed to apply then drop stash", e);
  } finally {
    close(git);
  }
}

代码示例来源:origin: alien4cloud/alien4cloud

public static void stash(Path repositoryDirectory, String stashId) {
  Git git = null;
  try {
    log.debug("Stashing change from <" + repositoryDirectory + "> to stash <" + stashId + ">");
    git = Git.open(repositoryDirectory.toFile());
    Collection<RevCommit> stashes = git.stashList().call();
    int stashIndex = 0;
    for (RevCommit stash : stashes) {
      if (stash.getFullMessage().equals(stashId)) {
        git.stashDrop().setStashRef(stashIndex).call();
        log.warn("Stash <" + stashId + "> was already existing in <" + repositoryDirectory + ">. It has been deleted.");
        break;
      }
      stashIndex++;
    }
    git.stashCreate().setIncludeUntracked(true).setWorkingDirectoryMessage(stashId).call();
  } catch (IOException | GitAPIException e) {
    throw new GitException("Failed to stash data", e);
  } finally {
    close(git);
  }
}

代码示例来源:origin: alien4cloud/alien4cloud

public static void applyStashThenDrop(Path repositoryDirectory, String stashId) {
  Git git = null;
  try {
    git = Git.open(repositoryDirectory.toFile());
    int stashIndex = 0;
    Collection<RevCommit> stashes = git.stashList().call();
    for (RevCommit stash : stashes) {
      if (stash.getFullMessage().equals(stashId)) {
        git.stashApply().setStashRef(stash.getName()).call();
        git.stashDrop().setStashRef(stashIndex).call();
        log.debug("Stash <" + stashId + ">  applied/dropped on <" + repositoryDirectory + ">");
        break;
      }
      stashIndex++;
    }
  } catch (IOException | GitAPIException e) {
    throw new GitException("Failed to apply then drop stash", e);
  } finally {
    close(git);
  }
}

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

int index = 0;
try {
  for (RevCommit commit : Git.wrap(repo).stashList().call())
    stashNodes.add(new StashedCommitNode(node, repo, index++,
        commit));

相关文章