@SuppressWarnings("unchecked") private void logDirty(Status status) { Set<String> dirties = dirties(status.getAdded(), status.getChanged(), status.getRemoved(), status.getMissing(), status.getModified(), status.getConflicting(), status.getUntracked()); this.logger.warn(format("Dirty files found: %s", dirties)); }
public static ArrayMemory valueOf(Status value) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("added").assign(ArrayMemory.ofStringCollection(value.getAdded())); memory.refOfIndex("changed").assign(ArrayMemory.ofStringCollection(value.getChanged())); memory.refOfIndex("conflicting").assign(ArrayMemory.ofStringCollection(value.getConflicting())); memory.refOfIndex("ignoredNotInIndex").assign(ArrayMemory.ofStringCollection(value.getIgnoredNotInIndex())); memory.refOfIndex("missing").assign(ArrayMemory.ofStringCollection(value.getMissing())); memory.refOfIndex("modified").assign(ArrayMemory.ofStringCollection(value.getModified())); memory.refOfIndex("removed").assign(ArrayMemory.ofStringCollection(value.getRemoved())); memory.refOfIndex("uncommittedChanges").assign(ArrayMemory.ofStringCollection(value.getUncommittedChanges())); memory.refOfIndex("untracked").assign(ArrayMemory.ofStringCollection(value.getUntracked())); memory.refOfIndex("untrackedFolders").assign(ArrayMemory.ofStringCollection(value.getUntrackedFolders())); return memory; }
private void pull() throws GitAPIException { Git git = recordGit(Git.wrap(repository)); PullCommand pull = git.pull() .setRebase(true); PullResult result = pull.call(); if (!result.isSuccessful()) { LOGGER.log(Level.WARNING, () -> String.format("Cannot pull from git '%s', branch '%s'", uri.toASCIIString(), branch)); if (LOGGER.isLoggable(Level.FINEST)) { Status status = git.status().call(); LOGGER.finest(() -> "git status cleanliness: " + status.isClean()); if (!status.isClean()) { LOGGER.finest(() -> "git status uncommitted changes: " + status.getUncommittedChanges()); LOGGER.finest(() -> "git status untracked: " + status.getUntracked()); } } } else { LOGGER.fine("Pull was successful."); } LOGGER.finest(() -> "git rebase result: " + result.getRebaseResult().getStatus().name()); LOGGER.finest(() -> "git fetch result: " + result.getFetchResult().getMessages()); }
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (Git git = new Git(repository)) { Status status = git.status().call(); System.out.println("Added: " + status.getAdded()); System.out.println("Changed: " + status.getChanged()); System.out.println("Conflicting: " + status.getConflicting()); System.out.println("ConflictingStageState: " + status.getConflictingStageState()); System.out.println("IgnoredNotInIndex: " + status.getIgnoredNotInIndex()); System.out.println("Missing: " + status.getMissing()); System.out.println("Modified: " + status.getModified()); System.out.println("Removed: " + status.getRemoved()); System.out.println("Untracked: " + status.getUntracked()); System.out.println("UntrackedFolders: " + status.getUntrackedFolders()); } } } }
/** * Returns the newly added artifact set relevant to the current status of the repository * * @param status git status * @return artifact names set */ private Set<String> getNewArtifacts(Status status) { return status.getUntracked(); }
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (Git git = new Git(repository)) { Status status = git.status().call(); System.out.println("Added: " + status.getAdded()); System.out.println("Changed: " + status.getChanged()); System.out.println("Conflicting: " + status.getConflicting()); System.out.println("ConflictingStageState: " + status.getConflictingStageState()); System.out.println("IgnoredNotInIndex: " + status.getIgnoredNotInIndex()); System.out.println("Missing: " + status.getMissing()); System.out.println("Modified: " + status.getModified()); System.out.println("Removed: " + status.getRemoved()); System.out.println("Untracked: " + status.getUntracked()); System.out.println("UntrackedFolders: " + status.getUntrackedFolders()); } } } }
Status status = git.status().call(); for( String fileName : status.getUntracked() ) { // delete fileName }
Set<String> untracked = status.getUntracked(); for(String untrack : untracked) { System.out.println("Untracked: " + untrack);
private Set<Path> getChangesFromStatus() throws GitAPIException { Set<String> changes = new HashSet<>(); Status status = git.status().call(); if (configuration.uncommited) { changes.addAll(status.getUncommittedChanges()); } if (configuration.untracked) { changes.addAll(status.getUntracked()); } return changes.stream() .map(workTree::resolve) .map(Path::normalize) .filter(this::pathNotExcluded) .collect(Collectors.toSet()); }
Set<String> untracked = status.getUntracked(); for(String untrack : untracked) { System.out.println("Untracked: " + untrack);
/** * Adds unversioned files to be tracked by the repository. * * @throws GitAPIException - failed. */ public void addWorkingChanges() throws GitAPIException { val status = git.status().call(); status.getUntracked().forEach(this::addFile); }
Status status = command.call(); Set<String> untrackedFiles = new TreeSet<>(status.getUntracked()); Set<String> untrackedDirs = new TreeSet<>( status.getUntrackedFolders());
@Override public Set<String> getUntracked() throws RepositoryException { return wrap(() -> git.status().call().getUntracked()); }
private boolean localRepoIsDirty(Git git) throws GitAPIException { Status status = git.status().call(); List potentialIssues = new ArrayList(); potentialIssues.addAll(status.getConflicting()); potentialIssues.addAll(status.getIgnoredNotInIndex()); potentialIssues.addAll(status.getAdded()); potentialIssues.addAll(status.getChanged()); potentialIssues.addAll(status.getMissing()); potentialIssues.addAll(status.getModified()); potentialIssues.addAll(status.getRemoved()); potentialIssues.addAll(status.getUncommittedChanges()); potentialIssues.addAll(status.getUntracked()); potentialIssues.addAll(status.getUntrackedFolders()); return !potentialIssues.isEmpty(); }
@SuppressWarnings("unchecked") private void logDirty(Status status) { Set<String> dirties = dirties(status.getAdded(), status.getChanged(), status.getRemoved(), status.getMissing(), status.getModified(), status.getConflicting(), status.getUntracked()); this.logger.warn(String.format("Dirty files found: %s", dirties)); }
private int countUntracked() throws GitAPIException { return git.status().call().getUntracked().size(); }
public File operateOn(Repository repo) throws Exception { Git git = new Git(repo); if (repo.getAllRefs().containsKey("refs/heads/master")) { git.reset().setMode(ResetCommand.ResetType.HARD).setRef("HEAD").call(); for (String path : git.status().call().getUntracked()) { new File(repo.getWorkTree(), path).delete(); } } return ZipWriter.addDirectoryContentsToJar(repo.getWorkTree(), ".git"); } });
protected boolean hasGitChanges(Git git) throws GitAPIException { Status status = git.status().call(); return anySetsNotEmpty(status.getAdded(), status.getChanged(), status.getModified(), status.getRemoved(), 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()); }
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()); }