@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()); }
/** * Return a command object used to drop a stashed commit * * @return a {@link org.eclipse.jgit.api.StashDropCommand} * @since 2.0 */ public StashDropCommand stashDrop() { return new StashDropCommand(repo); }
checkCallable(); Ref stashRef = getRef(); if (stashRef == null) return null; deleteRef(stashRef); return null; deleteRef(stashRef); return null; throw new JGitInternalException(JGitText.get().stashDropFailed, e); updateRef(stashRef, entryId);
ObjectId call = git.stashDrop().setStashRef(0).call(); System.out.println("StashDrop returned: " + call);
private void deleteRef(Ref stashRef) { try { Result result = createRefUpdate(stashRef).delete(); if (Result.FORCED != result) throw new JGitInternalException(MessageFormat.format( JGitText.get().stashDropDeleteRefFailed, result)); } catch (IOException e) { throw new JGitInternalException(JGitText.get().stashDropFailed, e); } }
@Override public void stashDrop(final Git repo) throws GitAPIException { repo.stashDrop().call(); }
checkCallable(); Ref stashRef = getRef(); if (stashRef == null) return null; deleteRef(stashRef); return null; deleteRef(stashRef); return null; throw new JGitInternalException(JGitText.get().stashDropFailed, e); updateRef(stashRef, entryId);
ObjectId call = git.stashDrop().setStashRef(0).call(); System.out.println("StashDrop returned: " + call);
private void updateRef(Ref stashRef, ObjectId newId) { try { RefUpdate update = createRefUpdate(stashRef); update.setNewObjectId(newId); Result result = update.update(); switch (result) { case FORCED: case NEW: case NO_CHANGE: return; default: throw new JGitInternalException(MessageFormat.format( JGitText.get().updatingRefFailed, R_STASH, newId, result)); } } catch (IOException e) { throw new JGitInternalException(JGitText.get().stashDropFailed, e); } }
checkCallable(); Ref stashRef = getRef(); if (stashRef == null) return null; deleteRef(stashRef); return null; deleteRef(stashRef); return null; throw new JGitInternalException(JGitText.get().stashDropFailed, e); updateRef(stashRef, entryId);
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); } }
private void deleteRef(Ref stashRef) { try { Result result = createRefUpdate(stashRef).delete(); if (Result.FORCED != result) throw new JGitInternalException(MessageFormat.format( JGitText.get().stashDropDeleteRefFailed, result)); } catch (IOException e) { throw new JGitInternalException(JGitText.get().stashDropFailed, e); } }
/** * Returns a command object used to drop a stashed commit * * @return a {@link StashDropCommand} * @since 2.0 */ public StashDropCommand stashDrop() { return new StashDropCommand(repo); }
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); } }
private void deleteRef(final Ref stashRef) { try { Result result = createRefUpdate(stashRef).delete(); if (Result.FORCED != result) throw new JGitInternalException(MessageFormat.format( JGitText.get().stashDropDeleteRefFailed, result)); } catch (IOException e) { throw new JGitInternalException(JGitText.get().stashDropFailed, e); } }
/** * Return a command object used to drop a stashed commit * * @return a {@link org.eclipse.jgit.api.StashDropCommand} * @since 2.0 */ public StashDropCommand stashDrop() { return new StashDropCommand(repo); }
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); } }
private void updateRef(Ref stashRef, ObjectId newId) { try { RefUpdate update = createRefUpdate(stashRef); update.setNewObjectId(newId); Result result = update.update(); switch (result) { case FORCED: case NEW: case NO_CHANGE: return; default: throw new JGitInternalException(MessageFormat.format( JGitText.get().updatingRefFailed, R_STASH, newId, result)); } } catch (IOException e) { throw new JGitInternalException(JGitText.get().stashDropFailed, e); } }
private void updateRef(Ref stashRef, ObjectId newId) { try { RefUpdate update = createRefUpdate(stashRef); update.setNewObjectId(newId); Result result = update.update(); switch (result) { case FORCED: case NEW: case NO_CHANGE: return; default: throw new JGitInternalException(MessageFormat.format( JGitText.get().updatingRefFailed, R_STASH, newId, result)); } } catch (IOException e) { throw new JGitInternalException(JGitText.get().stashDropFailed, e); } }