@Signature public Memory stashDrop(ArrayMemory settings) throws GitAPIException { StashDropCommand command = getWrappedObject().stashDrop(); if (settings != null) { command.setAll(settings.valueOfIndex("all").toBoolean()); Memory stashRef = settings.valueOfIndex("stashRef"); if (stashRef.isNotNull()) { command.setStashRef(stashRef.toInteger()); } } return GitUtils.valueOf(command.call()); }
ObjectId call = git.stashDrop().setStashRef(0).call(); System.out.println("StashDrop returned: " + call);
ObjectId call = git.stashDrop().setStashRef(0).call(); System.out.println("StashDrop returned: " + call);
@Override public void stashDrop(final Git repo) throws GitAPIException { repo.stashDrop().call(); }
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); } }