Question

I have a Maven Mojo plugin that interrogates the SCM to produce a report. It collects the comment, author and date entries fine. I now need the actual commit ID. So, given the following log statement...

commit 0559a4f75eaabb978cd880ae921ea7737b974580
Author: John Smith <jsmith@example.com>
Date:   Tue Jan 18 13:08:57 2011 -0500

    Fixed port numbers for JMX

I want to extract 0559a4f75eaabb978cd880ae921ea7737b974580

There doesn't seem to be an obvious way to do this. Any help would be appreciated. Here's how I'm getting ChangeSet in the first place.

SimpleDateFormat localFormat = new SimpleDateFormat(userDateFormat);
ScmRepository repository = getScmRepository();
ScmProvider provider = getScmManager().getProviderByRepository(repository);
ChangeLogScmResult result = provider.changeLog(repository, getFileSet(), this.parseDate(localFormat, this.startDate), this.parseDate(localFormat, this.endDate), 0, (ScmBranch) getScmVersion(scmVersionType, scmVersion), dateFormat);
checkResult(result);
ChangeLogSet changeLogSet = result.getChangeLog();
ChangeSet[] changeSets = (ChangeSet[]) changeLogSet.getChangeSets().toArray(new ChangeSet[changeLogSet.getChangeSets().size()]);
GitChangeSet changeSet = (GitChangeSet)changeSets[0];
String gitID = ???????????????????????????????

Here's the API docs for the GitChangeSet http://maven.apache.org/scm/apidocs/org/apache/maven/scm/provider/git/GitChangeSet.html from which you can get most of the rest of the stuff I'm doing.

Was it helpful?

Solution

Older versions of the maven-scm providers do not have this functionality. Upgrade to the newer versions and the "getRevision()" method on ChangeSet should do you well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top