FS.DETECTED)) {
throw new BuildException("Specified path (" + src
+ ") is not a git repository.");
}
AddCommand gitAdd;
try {
Repository repo = new FileRepositoryBuilder().readEnvironment()
.findGitDir(src).build();
gitAdd = new Git(repo).add();
} catch (IOException e) {
throw new BuildException("Could not access repository " + src, e);
}
try {
String prefix = src.getCanonicalPath();
String[] allFiles = getPath().list();
for (String file : allFiles) {
String toAdd = translateFilePathUsingPrefix(file, prefix);
log("Adding " + toAdd, Project.MSG_VERBOSE);
gitAdd.addFilepattern(toAdd);
}
gitAdd.call();
} catch (Exception e) {
throw new BuildException("Could not add files to index." + src, e);
}
}