@Signature public Memory stashList() throws GitAPIException { StashListCommand command = getWrappedObject().stashList(); return GitUtils.valueOfRevCommits(command.call()); }
Collection<RevCommit> stashes = git.stashList().call(); for(RevCommit rev : stashes) { System.out.println("Found stash: " + rev + ": " + rev.getFullMessage());
Collection<RevCommit> stashes = git.stashList().call(); for(RevCommit rev : stashes) { System.out.println("Found stash: " + rev + ": " + rev.getFullMessage());
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<>(); }
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); } }
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); } }
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); } }
int index = 0; try { for (RevCommit commit : Git.wrap(repo).stashList().call()) stashNodes.add(new StashedCommitNode(node, repo, index++, commit));