org.eclipse.jgit.api.Status status = Git.wrap(repo) .status().setIgnoreSubmodules(IgnoreSubmoduleMode.ALL).call(); if (status.hasUncommittedChanges()) { List<String> list = new ArrayList<>(); list.addAll(status.getUncommittedChanges());
boolean isGitDirectoryClean() throws GitAPIException { final Status status = new Git(gitRepo).status().call(); return status.isClean() && !status.hasUncommittedChanges(); }
@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 void convertStatus(org.eclipse.jgit.api.Status status) { if (!status.hasUncommittedChanges() && status.isClean()) { mResult.append("Nothing to commit, working directory clean"); return; } // TODO if working dir not clean convertStatusSet("Added files:", status.getAdded()); convertStatusSet("Changed files:", status.getChanged()); convertStatusSet("Removed files:", status.getRemoved()); convertStatusSet("Missing files:", status.getMissing()); convertStatusSet("Modified files:", status.getModified()); convertStatusSet("Conflicting files:", status.getConflicting()); convertStatusSet("Untracked files:", status.getUntracked()); }
private void convertStatus(org.eclipse.jgit.api.Status status) { if (!status.hasUncommittedChanges() && status.isClean()) { mResult.append("Nothing to commit, working directory clean"); return; } // TODO if working dir not clean convertStatusSet("Added files:", status.getAdded()); convertStatusSet("Changed files:", status.getChanged()); convertStatusSet("Removed files:", status.getRemoved()); convertStatusSet("Missing files:", status.getMissing()); convertStatusSet("Modified files:", status.getModified()); convertStatusSet("Conflicting files:", status.getConflicting()); convertStatusSet("Untracked files:", status.getUntracked()); }
@Override public void addCommitPush() { try { Git git = gitOpen(); git.add().addFilepattern(".").call(); // status Status status=git.status().call(); // rm the deleted ones if(status.getMissing().size() >0){ for(String rm : status.getMissing()){ git.rm().addFilepattern(rm).call(); } } // commit and push if needed if(!status.hasUncommittedChanges()){ log.debug("not commiting git, because there are no changes"); return; } git.commit().setMessage("Automatic commit by releasetrain").call(); git.push().setCredentialsProvider(credentialsProvider()).call(); } catch (Exception e) { throw new GitException(e.getMessage(), e); } }
org.eclipse.jgit.api.Status status = Git.wrap(repo) .status().setIgnoreSubmodules(IgnoreSubmoduleMode.ALL).call(); if (status.hasUncommittedChanges()) { List<String> list = new ArrayList<String>(); list.addAll(status.getUncommittedChanges());
org.eclipse.jgit.api.Status status = Git.wrap(repo) .status().setIgnoreSubmodules(IgnoreSubmoduleMode.ALL).call(); if (status.hasUncommittedChanges()) { List<String> list = new ArrayList<>(); list.addAll(status.getUncommittedChanges());