Get CommitMessage by commitID

Answered

I'm developing a IDEA plugin with idea4git and I need to get commit message by commit id which is get from VcsFullCommitDetails.getId.asString

I think I can get it by GitHistoryUtils.collectCommitsMetadata but I have no idea have to use it.Can anyone give me some suggestion?what's more, If I want to get changeList of the commit,which method should I use?

1
1 comment

I found the solution. By using GitHistoryUtils.loadDetails can get commit detail. Here is the code below:

List<String>commitIdList;   //suppose we have commit Id list here

var gitRespositoryManager = GitRespositoryManager.getInstance(project);
var gitRepository = gitRespositoryManager.getRepositoryForFile(LocalFileSystem.getInstance().findFileByPath(project.getBasePath()));
GitHistoryUtils.loadDetails(project,gitRepository.getRoot(),gitCommit->{
    gitCommit.getId();// Here is the commitId
    gitCommit.getFullMessage();// Here is the commit message
    gitCommit.getChanges();  //Here is the commit change list
},GitHistoryUtils.formHashParameters(gitRepository.getVcs(),commitIdList));
2

Please sign in to leave a comment.