@Signature public Memory commit(String message, ArrayMemory settings) throws GitAPIException { CommitCommand commit = getWrappedObject().commit(); commit.setMessage(message); if (settings != null && settings.isNotNull()) { commit.setAll(settings.valueOfIndex("all").toBoolean()); commit.setAllowEmpty(settings.valueOfIndex("allowEmpty").toBoolean()); commit.setAmend(settings.valueOfIndex("amend").toBoolean()); commit.setInsertChangeId(settings.valueOfIndex("insertChangeId").toBoolean()); commit.setNoVerify(settings.valueOfIndex("noVerify").toBoolean()); Memory author = settings.valueOfIndex("author"); if (author.isArray()) { commit.setAuthor(author.valueOfIndex("name").toString(), author.valueOfIndex("email").toString()); } Memory committer = settings.valueOfIndex("committer"); if (committer.isArray()) { commit.setCommitter(committer.valueOfIndex("name").toString(), committer.valueOfIndex("email").toString()); } if (settings.containsKey("only")) { commit.setOnly(settings.valueOfIndex("only").toString()); } if (settings.containsKey("reflogComment")) { commit.setReflogComment(settings.valueOfIndex("reflogComment").toString()); } } RevCommit call = commit.call(); return GitUtils.valueOf(call); }
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; }
try (Git git = new Git(repo)) { newHead = git.commit().setMessage(newMessage).setAmend(true) .setNoVerify(true).call();
+ srcCommit.getShortMessage()) .setAuthor(srcCommit.getAuthorIdent()) .setNoVerify(true).call(); cherryPickedRefs.add(src); } else {
protected void gitCommit(String msg) { try (Git git = repository.getGit()) { if(!git.status().call().isClean()) { git.commit().setMessage(msg).setAll(true).setNoVerify(true).call(); } } catch (GitAPIException e) { MGMT_OP_LOGGER.failedToStoreConfiguration(e, file.getName()); } }
protected void gitCommit(String msg) { try (Git git = repository.getGit()) { if(!git.status().call().isClean()) { git.commit().setMessage(msg).setAll(true).setNoVerify(true).call(); } } catch (GitAPIException e) { MGMT_OP_LOGGER.failedToStoreConfiguration(e, file.getName()); } }
@Override public String snapshot(String name, String comment) throws ConfigurationPersistenceException { boolean noComment = (comment ==null || comment.isEmpty()); String message = noComment ? SNAPSHOT_PREFIX + FORMATTER.format(LocalDateTime.now()) : comment; String tagName = (name ==null || name.isEmpty()) ? SNAPSHOT_PREFIX + FORMATTER.format(LocalDateTime.now()) : name; try (Git git = gitRepository.getGit()) { Status status = git.status().call(); List<Ref> tags = git.tagList().call(); String refTagName = R_TAGS + tagName; for(Ref tag : tags) { if(refTagName.equals(tag.getName())) { throw MGMT_OP_LOGGER.snapshotAlreadyExistError(tagName); } } //if comment is not null if(status.hasUncommittedChanges() || !noComment) { git.commit().setMessage(message).setAll(true).setNoVerify(true).call(); } git.tag().setName(tagName).setMessage(message).call(); } catch (GitAPIException ex) { throw MGMT_OP_LOGGER.failedToPersistConfiguration(ex, message, ex.getMessage()); } return message; }
@Override public String snapshot(String name, String comment) throws ConfigurationPersistenceException { boolean noComment = (comment ==null || comment.isEmpty()); String message = noComment ? SNAPSHOT_PREFIX + FORMATTER.format(LocalDateTime.now()) : comment; String tagName = (name ==null || name.isEmpty()) ? SNAPSHOT_PREFIX + FORMATTER.format(LocalDateTime.now()) : name; try (Git git = gitRepository.getGit()) { Status status = git.status().call(); List<Ref> tags = git.tagList().call(); String refTagName = R_TAGS + tagName; for(Ref tag : tags) { if(refTagName.equals(tag.getName())) { throw MGMT_OP_LOGGER.snapshotAlreadyExistError(tagName); } } //if comment is not null if(status.hasUncommittedChanges() || !noComment) { git.commit().setMessage(message).setAll(true).setNoVerify(true).call(); } git.tag().setName(tagName).setMessage(message).call(); } catch (GitAPIException ex) { throw MGMT_OP_LOGGER.failedToPersistConfiguration(ex, message, ex.getMessage()); } return message; }
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 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; }
/** * Commit all changes if there are uncommitted changes. * * @param msg the commit message. * @throws GitAPIException */ public void commit(String msg) throws GitAPIException { try (Git git = getGit()) { Status status = git.status().call(); if (!status.isClean()) { git.commit().setMessage(msg).setAll(true).setNoVerify(true).call(); } } } }
/** * Commit all changes if there are uncommitted changes. * * @param msg the commit message. * @throws GitAPIException */ public void commit(String msg) throws GitAPIException { try (Git git = getGit()) { Status status = git.status().call(); if (!status.isClean()) { git.commit().setMessage(msg).setAll(true).setNoVerify(true).call(); } } } }
@Override public void flush(boolean success) { if (success) { try (Git git = gitRepository.getGit()) { Status status = git.status().call(); if (!status.isClean()) { String message = git.getRepository().parseCommit(git.getRepository().resolve(HEAD)).getFullMessage(); if(! status.getUntracked().isEmpty() || ! status.getUntrackedFolders().isEmpty()) { AddCommand addCommand = git.add(); for(String untracked : status.getUntrackedFolders()) { addCommand = addCommand.addFilepattern(untracked); } for(String untracked : status.getUntracked()) { addCommand = addCommand.addFilepattern(untracked); } addCommand.call(); } git.commit().setMessage(message).setAmend(true).setAll(true).setNoVerify(true).call(); } } catch (RevisionSyntaxException | IOException | GitAPIException ex) { throw new RuntimeException(ex); } } }
@Override public void flush(boolean success) { if (success) { try (Git git = gitRepository.getGit()) { Status status = git.status().call(); if (!status.isClean()) { String message = git.getRepository().parseCommit(git.getRepository().resolve(HEAD)).getFullMessage(); if(! status.getUntracked().isEmpty() || ! status.getUntrackedFolders().isEmpty()) { AddCommand addCommand = git.add(); for(String untracked : status.getUntrackedFolders()) { addCommand = addCommand.addFilepattern(untracked); } for(String untracked : status.getUntracked()) { addCommand = addCommand.addFilepattern(untracked); } addCommand.call(); } git.commit().setMessage(message).setAmend(true).setAll(true).setNoVerify(true).call(); } } catch (RevisionSyntaxException | IOException | GitAPIException ex) { throw new RuntimeException(ex); } } }
.modifyCommitMessage(oldMessage); newHead = new Git(repo).commit().setMessage(newMessage) .setAmend(true).setNoVerify(true).call(); return null; case EDIT:
try (Git git = new Git(repo)) { newHead = git.commit().setMessage(newMessage).setAmend(true) .setNoVerify(true).call();
+ srcCommit.getShortMessage()) .setAuthor(srcCommit.getAuthorIdent()) .setNoVerify(true).call(); cherryPickedRefs.add(src); } else {
+ srcCommit.getShortMessage()) .setAuthor(srcCommit.getAuthorIdent()) .setNoVerify(true).call(); cherryPickedRefs.add(src); } else {