@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); }
public void commit(List<String> paths, String msg) throws Exception { CommitCommand commit = git.commit().setMessage(msg); for (String path : paths) commit.setOnly(path); commit.call(); }
public void commit(String path, String msg) throws Exception { git.commit().setOnly(path).setMessage(msg).call(); }
public void commitFile() throws IOException { final FileRepositoryBuilder builder = new FileRepositoryBuilder(); final Repository repository = builder.setWorkTree(new File(gitDir)).findGitDir().build(); try { new Git(repository).commit().setOnly("build.gradle").setMessage("Bump the version of builld.gradle").call(); } catch (final GitAPIException e) { e.printStackTrace(); } }
.setMessage(commitMessage) .setCommitter(data.getAuthor(), "") .setOnly(markerFile) .call();
@Override public FileData rename(String srcName, FileData destData) throws IOException { Lock writeLock = repositoryLock.writeLock(); try { writeLock.lock(); File src = new File(localRepositoryPath, srcName); File dest = new File(localRepositoryPath, destData.getName()); FileUtils.move(src, dest); git.rm().addFilepattern(srcName).call(); git.add().addFilepattern(destData.getName()).call(); RevCommit commit = git.commit() .setMessage(StringUtils.trimToEmpty(destData.getComment())) .setCommitter(destData.getAuthor(), "") .setOnly(srcName) .setOnly(destData.getName()) .call(); addTagToCommit(commit); push(); } catch (Exception e) { reset(); throw new IOException(e); } finally { writeLock.unlock(); } return check(destData.getName()); }
@Override public FileData save(FileData data, InputStream stream) throws IOException { Lock writeLock = repositoryLock.writeLock(); try { writeLock.lock(); String fileInRepository = data.getName(); File file = new File(localRepositoryPath, fileInRepository); createParent(file); IOUtils.copyAndClose(stream, new FileOutputStream(file)); git.add().addFilepattern(fileInRepository).call(); // TODO: Add possibility to set committer email RevCommit commit = git.commit() .setMessage(StringUtils.trimToEmpty(data.getComment())) .setCommitter(data.getAuthor(), "") .setOnly(fileInRepository) .call(); addTagToCommit(commit); push(); } catch (Exception e) { reset(); throw new IOException(e); } finally { writeLock.unlock(); } return check(data.getName()); }
.setMessage(StringUtils.trimToEmpty(folderData.getComment())) .setCommitter(folderData.getAuthor(), "") .setOnly(relativeFolder) .call();
if (!paths.isEmpty()) for (String p : paths) commitCmd.setOnly(p); commitCmd.setAmend(amend); commitCmd.setAll(all);