private void checkSteps(List<RebaseTodoLine> steps) throws InvalidRebaseStepException, IOException { if (steps.isEmpty()) return; if (RebaseTodoLine.Action.SQUASH.equals(steps.get(0).getAction()) || RebaseTodoLine.Action.FIXUP.equals(steps.get(0).getAction())) { if (!rebaseState.getFile(DONE).exists() || rebaseState.readFile(DONE).trim().length() == 0) { throw new InvalidRebaseStepException(MessageFormat.format( JGitText.get().cannotSquashFixupWithoutPreviousCommit, steps.get(0).getAction().name())); } } }
sb.append(step.getComment()); else { sb.append(step.getAction().toToken()); sb.append(" "); //$NON-NLS-1$ sb.append(step.getCommit().name());
/** * Removes the number of lines given in the parameter from the * <code>git-rebase-todo</code> file but preserves comments and other lines * that can not be parsed as steps * * @param numSteps * @throws IOException */ private void popSteps(int numSteps) throws IOException { if (numSteps == 0) return; List<RebaseTodoLine> todoLines = new LinkedList<>(); List<RebaseTodoLine> poppedLines = new LinkedList<>(); for (RebaseTodoLine line : repo.readRebaseTodo( rebaseState.getPath(GIT_REBASE_TODO), true)) { if (poppedLines.size() >= numSteps || RebaseTodoLine.Action.COMMENT.equals(line.getAction())) todoLines.add(line); else poppedLines.add(line); } repo.writeRebaseTodoFile(rebaseState.getPath(GIT_REBASE_TODO), todoLines, false); if (poppedLines.size() > 0) { repo.writeRebaseTodoFile(rebaseState.getPath(DONE), poppedLines, true); } }
private RevCommit squashIntoPrevious(boolean sequenceContainsSquash, RebaseTodoLine nextStep) throws IOException, GitAPIException { RevCommit retNewHead; String commitMessage = rebaseState .readFile(MESSAGE_SQUASH); try (Git git = new Git(repo)) { if (nextStep == null || ((nextStep.getAction() != Action.FIXUP) && (nextStep.getAction() != Action.SQUASH))) { // this is the last step in this sequence if (sequenceContainsSquash) { commitMessage = interactiveHandler .modifyCommitMessage(commitMessage); } retNewHead = git.commit() .setMessage(stripCommentLines(commitMessage)) .setAmend(true).setNoVerify(true).call(); rebaseState.getFile(MESSAGE_SQUASH).delete(); rebaseState.getFile(MESSAGE_FIXUP).delete(); } else { // Next step is either Squash or Fixup retNewHead = git.commit().setMessage(commitMessage) .setAmend(true).setNoVerify(true).call(); } } return retNewHead; }
private RebaseResult processStep(RebaseTodoLine step, boolean shouldPick) throws IOException, GitAPIException { if (Action.COMMENT.equals(step.getAction())) return null; if (preserveMerges && shouldPick && (Action.EDIT.equals(step.getAction()) || Action.PICK .equals(step.getAction()))) { writeRewrittenHashes(); switch (step.getAction()) { case PICK: return null; // continue rebase process on pick command
private void checkSteps(List<RebaseTodoLine> steps) throws InvalidRebaseStepException, IOException { if (steps.isEmpty()) return; if (RebaseTodoLine.Action.SQUASH.equals(steps.get(0).getAction()) || RebaseTodoLine.Action.FIXUP.equals(steps.get(0).getAction())) { if (!rebaseState.getFile(DONE).exists() || rebaseState.readFile(DONE).trim().length() == 0) { throw new InvalidRebaseStepException(MessageFormat.format( JGitText.get().cannotSquashFixupWithoutPreviousCommit, steps.get(0).getAction().name())); } } }
private void checkSteps(List<RebaseTodoLine> steps) throws InvalidRebaseStepException, IOException { if (steps.isEmpty()) return; if (RebaseTodoLine.Action.SQUASH.equals(steps.get(0).getAction()) || RebaseTodoLine.Action.FIXUP.equals(steps.get(0).getAction())) { if (!rebaseState.getFile(DONE).exists() || rebaseState.readFile(DONE).trim().length() == 0) { throw new InvalidRebaseStepException(MessageFormat.format( JGitText.get().cannotSquashFixupWithoutPreviousCommit, steps.get(0).getAction().name())); } } }
sb.append(step.getComment()); else { sb.append(step.getAction().toToken()); sb.append(" "); //$NON-NLS-1$ sb.append(step.getCommit().name());
sb.append(step.getComment()); else { sb.append(step.getAction().toToken()); sb.append(" "); //$NON-NLS-1$ sb.append(step.getCommit().name());
/** * Removes the number of lines given in the parameter from the * <code>git-rebase-todo</code> file but preserves comments and other lines * that can not be parsed as steps * * @param numSteps * @throws IOException */ private void popSteps(int numSteps) throws IOException { if (numSteps == 0) return; List<RebaseTodoLine> todoLines = new LinkedList<>(); List<RebaseTodoLine> poppedLines = new LinkedList<>(); for (RebaseTodoLine line : repo.readRebaseTodo( rebaseState.getPath(GIT_REBASE_TODO), true)) { if (poppedLines.size() >= numSteps || RebaseTodoLine.Action.COMMENT.equals(line.getAction())) todoLines.add(line); else poppedLines.add(line); } repo.writeRebaseTodoFile(rebaseState.getPath(GIT_REBASE_TODO), todoLines, false); if (poppedLines.size() > 0) { repo.writeRebaseTodoFile(rebaseState.getPath(DONE), poppedLines, true); } }
/** * Removes the number of lines given in the parameter from the * <code>git-rebase-todo</code> file but preserves comments and other lines * that can not be parsed as steps * * @param numSteps * @throws IOException */ private void popSteps(int numSteps) throws IOException { if (numSteps == 0) return; List<RebaseTodoLine> todoLines = new LinkedList<RebaseTodoLine>(); List<RebaseTodoLine> poppedLines = new LinkedList<RebaseTodoLine>(); for (RebaseTodoLine line : repo.readRebaseTodo( rebaseState.getPath(GIT_REBASE_TODO), true)) { if (poppedLines.size() >= numSteps || RebaseTodoLine.Action.COMMENT.equals(line.getAction())) todoLines.add(line); else poppedLines.add(line); } repo.writeRebaseTodoFile(rebaseState.getPath(GIT_REBASE_TODO), todoLines, false); if (poppedLines.size() > 0) { repo.writeRebaseTodoFile(rebaseState.getPath(DONE), poppedLines, true); } }
private RevCommit squashIntoPrevious(boolean sequenceContainsSquash, RebaseTodoLine nextStep) throws IOException, GitAPIException { RevCommit retNewHead; String commitMessage = rebaseState .readFile(MESSAGE_SQUASH); try (Git git = new Git(repo)) { if (nextStep == null || ((nextStep.getAction() != Action.FIXUP) && (nextStep.getAction() != Action.SQUASH))) { // this is the last step in this sequence if (sequenceContainsSquash) { commitMessage = interactiveHandler .modifyCommitMessage(commitMessage); } retNewHead = git.commit() .setMessage(stripCommentLines(commitMessage)) .setAmend(true).setNoVerify(true).call(); rebaseState.getFile(MESSAGE_SQUASH).delete(); rebaseState.getFile(MESSAGE_FIXUP).delete(); } else { // Next step is either Squash or Fixup retNewHead = git.commit().setMessage(commitMessage) .setAmend(true).setNoVerify(true).call(); } } return retNewHead; }
private RebaseResult processStep(RebaseTodoLine step, boolean shouldPick) throws IOException, GitAPIException { if (Action.COMMENT.equals(step.getAction())) return null; if (preserveMerges && shouldPick && (Action.EDIT.equals(step.getAction()) || Action.PICK .equals(step.getAction()))) { writeRewrittenHashes(); switch (step.getAction()) { case PICK: return null; // continue rebase process on pick command
private RevCommit squashIntoPrevious(boolean sequenceContainsSquash, RebaseTodoLine nextStep) throws IOException, GitAPIException { RevCommit retNewHead; String commitMessage = rebaseState .readFile(MESSAGE_SQUASH); try (Git git = new Git(repo)) { if (nextStep == null || ((nextStep.getAction() != Action.FIXUP) && (nextStep.getAction() != Action.SQUASH))) { // this is the last step in this sequence if (sequenceContainsSquash) { commitMessage = interactiveHandler .modifyCommitMessage(commitMessage); } retNewHead = git.commit() .setMessage(stripCommentLines(commitMessage)) .setAmend(true).setNoVerify(true).call(); rebaseState.getFile(MESSAGE_SQUASH).delete(); rebaseState.getFile(MESSAGE_FIXUP).delete(); } else { // Next step is either Squash or Fixup retNewHead = git.commit().setMessage(commitMessage) .setAmend(true).setNoVerify(true).call(); } } return retNewHead; }
private RebaseResult processStep(RebaseTodoLine step, boolean shouldPick) throws IOException, GitAPIException { if (Action.COMMENT.equals(step.getAction())) return null; if (preserveMerges && shouldPick && (Action.EDIT.equals(step.getAction()) || Action.PICK .equals(step.getAction()))) { writeRewrittenHashes(); switch (step.getAction()) { case PICK: return null; // continue rebase process on pick command