-1

I am using the below code to commit my changes.

CommitCommand commitCommand = git.commit();
commitCommand.setMessage("My change");
commitCommand.setAuthor(name, name + "@xyz.com");
commitCommand.call();

I want to know the commit id of this change. Because there can be a || process committing between the time I get the latest commit id and this particular commit. So to get the changes happening in this particular commit I need the commit id of the above commit. AFAIK CommitCommand does not have a getID() API.

torek
  • 448,244
  • 59
  • 642
  • 775

1 Answers1

0

One option could be use RevCommit like below snippet :

        //Run commit cmd with commit msg
    RevCommit revCommit = git.commit()
            .setMessage(commitMsg)
            .call();
    log.info("Commint ID " + revCommit.getId().getName());
Abhishek
  • 1,558
  • 16
  • 28