}
public Map<String, String> getInfo(MavenProject project) {
File basedir = project.getBasedir();
InfoScmResult result = null;
ScmLogger logger = new DefaultLog();
GitCommand command = new GitExeScmProvider().getInfoCommand();
command.setLogger(logger);
try {
ScmProviderRepository repository = new GitScmProviderRepository(basedir.getAbsolutePath());
ScmFileSet fileSet = new ScmFileSet(basedir);
CommandParameters parameters = new CommandParameters();
result = (InfoScmResult) command.execute(repository, fileSet, parameters);
} catch (ScmException e) {
if (logger.isErrorEnabled()) {
logger.error(e.getMessage());
}
}
Map<String, String> info = new LinkedHashMap<String, String>();
if (result != null) {
if (result.isSuccess()) {
List<InfoItem> items = result.getInfoItems();
if ((items != null) && (items.size() == 1)) {
info.put("git.revision", items.get(0).getRevision());
info.put("git.author", items.get(0).getLastChangedAuthor());
info.put("git.repository", items.get(0).getRepositoryUUID());
info.put("git.date", items.get(0).getLastChangedDate());
} else {
info.put("git.error", "The command returned incorrect number of arguments");
}
} else {
info.put("git.error", result.getProviderMessage());
}
}
return info;
}