java - 使用 JGit 库提交后如何获取提交的 id
问题描述
我正在使用下面的代码来提交我的更改。
CommitCommand commitCommand = git.commit();
commitCommand.setMessage("My change");
commitCommand.setAuthor(name, name + "@xyz.com");
commitCommand.call();
我想知道此更改的提交 ID。因为可以有 || 在我获得最新的提交 ID 和这个特定的提交之间的过程提交。因此,要在此特定提交中发生更改,我需要上述提交的提交 ID。AFAIK CommitCommand 没有 getID() API。
解决方案
一种选择是使用RevCommit,如下所示:
//Run commit cmd with commit msg
RevCommit revCommit = git.commit()
.setMessage(commitMsg)
.call();
log.info("Commint ID " + revCommit.getId().getName());
推荐阅读
- swift - 允许放大 WKWebView
- kubernetes - 如何使用 SDK 在 Kubernetes Operator 中观察 Pod api 端点
- c# - VS Code Intellisense 不适用于 nuget 包
- laravel - 我如何在我的 Laravel api 中为移动应用程序集成 ccavenue 支付网关
- asp.net-core - 为什么 FileVersion 和 AssemblyVersion 扩展为 4 位?
- xslt - 仅使用 XSLT 转换更改少量标签
- java - Webapp 部署失败,接口从类加载器异常中不可见
- reactjs - 反应最终形式不适用于打字稿
- mongodb - MongoDB 索引未与聚合查询一起使用
- linux - 如何调用 dpkg-buildflags 进行手动编译?