*/
@Override
public RevisionMetadata getMetadata(Revision revision) {
GitClonedRepository headClone = headCloneSupplier.get();
if (!headClone.getRepositoryName().equals(revision.repositoryName)) {
throw new MoeProblem(
String.format("Could not get metadata: Revision %s is in repository %s instead of %s",
revision.revId, revision.repositoryName, headClone.getRepositoryName()));
}
// Format: hash, author, date, parents, full commit message (subject and body)
String format = Joiner.on(LOG_DELIMITER).join("%H", "%an", "%ad", "%P", "%B");
String log;
try {
log = headClone.runGitCommand(
"log",
// Ensure one revision only, to be safe.
"--max-count=1",
"--format=" + format,
revision.revId);
} catch (CommandException e) {
throw new MoeProblem(
String.format("Failed git run: %d %s %s", e.returnStatus, e.stdout, e.stderr));
}
return parseMetadata(log);
}