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; }
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()); } } } }
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()); } } } }
Set<String> untrackedFolders = status.getUntrackedFolders(); for(String untrack : untrackedFolders) { System.out.println("Untracked Folder: " + untrack);
Set<String> untrackedFolders = status.getUntrackedFolders(); for(String untrack : untrackedFolders) { System.out.println("Untracked Folder: " + untrack);
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(); }
public GitManager addExternallyChangedFiles( final ChangeSummary changeSummary ) throws GitSubsystemException { lockAnd((me)->{ Status status = getStatus(); final Set<String> toAdd = new HashSet<>(); final Set<String> modified = status.getModified(); if ( modified != null && !modified.isEmpty() ) { toAdd.addAll( modified ); } final Set<String> untracked = status.getUntracked(); if ( untracked != null && !untracked.isEmpty() ) { toAdd.addAll( untracked ); } final Set<String> untrackedFolders = status.getUntrackedFolders(); if ( untrackedFolders != null && !untrackedFolders.isEmpty() ) { toAdd.addAll( untrackedFolders ); } if ( !toAdd.isEmpty() ) { addPaths( changeSummary, toAdd ); } return me; }); return this; }
sbInfo.append("Removed: ").append(status.getRemoved()).append("\n"); sbInfo.append("Untracked: ").append(status.getUntracked()).append("\n"); sbInfo.append("UntrackedFolders: ").append(status.getUntrackedFolders()).append("\n");
protected boolean isClean(Git git) throws GitAPIException, IOException { if (git.getRepository().getBranch().equals(BASE_BRANCH)) { Optional<Ref> baseBranch = getOriginHead(git); if (baseBranch.isPresent()) { RevWalk walk = new RevWalk(git.getRepository()); RevCommit baseCommit = walk.parseCommit(getBaseObjectId(git)); RevCommit headCommit = walk.parseCommit(getHead(git).getObjectId()); log.info(String.format("origin/master sha: [%s], head: [%s]", baseCommit.getName(), headCommit.getName())); return baseCommit.equals(headCommit) && git.status().call().isClean(); } else { // there is no origin Status status = git.status().call(); boolean isClean = status.isClean(); if (!isClean) { log.info("Untracked Folders: " + Arrays.toString(status.getUntrackedFolders().toArray())); log.info("Untracked Files: " + Arrays.toString(status.getUntracked().toArray())); log.info("Changed Files: " + Arrays.toString(status.getChanged().toArray())); log.info("Added Files: " + Arrays.toString(status.getAdded().toArray())); log.info("Removed Files: " + Arrays.toString(status.getRemoved().toArray())); log.info("Uncommitted Files: " + Arrays.toString(status.getUncommittedChanges().toArray())); } return isClean; } } return false; }
filesChanged.addAll(gitStatus.getUncommittedChanges()); filesChanged.addAll(gitStatus.getUntracked()); filesChanged.addAll(gitStatus.getUntrackedFolders());
status.getUntracked()); Set<String> untrackedAndIgnoredDirs = new TreeSet<String>( status.getUntrackedFolders());
@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); } } }