use of org.eclipse.jgit.errors.NoWorkTreeException in project fuse-karaf by jboss-fuse.
the class GitPatchRepositoryIT method mainRepository.
@Test
public void mainRepository() throws IOException, GitAPIException {
Git main = repository.findOrCreateMainGitRepository();
assertNotNull(main);
assertTrue(main.getRepository().isBare());
try {
main.getRepository().getWorkTree();
fail("Should not contain working tree");
} catch (NoWorkTreeException ignored) /* expected */
{
}
assertThat("Should contain single ref", new File(main.getRepository().getDirectory(), "refs/heads").listFiles().length, equalTo(1));
File theOnlyHead = new File(main.getRepository().getDirectory(), "refs/heads/" + GitPatchRepository.HISTORY_BRANCH);
assertTrue(theOnlyHead.exists());
}
use of org.eclipse.jgit.errors.NoWorkTreeException in project indy by Commonjava.
the class GitManager method getStatus.
private Status getStatus() throws GitSubsystemException {
Status status;
try {
status = git.status().call();
} catch (NoWorkTreeException | GitAPIException e) {
throw new GitSubsystemException("Failed to retrieve status of: %s. Reason: %s", e, rootDir, e.getMessage());
}
final Map<String, StageState> css = status.getConflictingStageState();
if (!css.isEmpty()) {
throw new GitSubsystemException("%s contains conflicts. Cannot auto-commit.\n %s", rootDir, new JoinString("\n ", css.entrySet()));
}
return status;
}
use of org.eclipse.jgit.errors.NoWorkTreeException in project indy by Commonjava.
the class GitManager method commitModifiedFiles.
public GitManager commitModifiedFiles(final ChangeSummary changeSummary) throws GitSubsystemException {
lockAnd((me) -> {
Status status;
try {
status = git.status().call();
} catch (NoWorkTreeException | GitAPIException e) {
throw new GitSubsystemException("Failed to retrieve status of: %s. Reason: %s", e, rootDir, e.getMessage());
}
final Map<String, StageState> css = status.getConflictingStageState();
if (!css.isEmpty()) {
throw new GitSubsystemException("%s contains conflicts. Cannot auto-commit.\n %s", rootDir, new JoinString("\n ", css.entrySet()));
}
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);
// for ( String folderPath : untrackedFolders )
// {
// File dir = new File( rootDir, folderPath );
// Files.walkFileTree( null, null )
// }
}
if (!toAdd.isEmpty()) {
addAndCommitPaths(changeSummary, toAdd);
}
return me;
});
return this;
}
use of org.eclipse.jgit.errors.NoWorkTreeException in project fabric8 by jboss-fuse.
the class GitPatchRepositoryIT method mainRepository.
@Test
public void mainRepository() throws IOException, GitAPIException {
Git main = repository.findOrCreateMainGitRepository();
assertNotNull(main);
assertTrue(main.getRepository().isBare());
try {
main.getRepository().getWorkTree();
fail("Should not contain working tree");
} catch (NoWorkTreeException expected) {
}
assertThat("Should contain single ref", new File(main.getRepository().getDirectory(), "refs/heads").listFiles().length, equalTo(1));
File theOnlyHead = new File(main.getRepository().getDirectory(), "refs/heads/" + GitPatchRepository.HISTORY_BRANCH);
assertTrue(theOnlyHead.exists());
}
Aggregations