node.js - NODEGIT - 向特定提交添加注释以存储元数据
问题描述
我读过git-notes
可用于将自定义信息(例如元数据)添加到特定提交,但我找不到如何做到这一点nodegit
目前我正在提交这样的回购,它工作正常
// git add --all
let repo = await Git.Repository.open(pathToSomewhere);
let index = await repo.index();
await index.addAll();
await index.write();
let oid = await index.writeTree();
// git commit -am ...
let commitAuthor = Git.Signature.now(authorName, authorEmail);
if (initial){
await repo.createCommit("HEAD", commitAuthor, commitAuthor, commitMessage, oid, []);
} else {
let head = await Git.Reference.nameToId(repo, "HEAD");
let parent = await repo.getCommit(head);
await repo.createCommit("HEAD", commitAuthor, commitAuthor, commitMessage, oid, [parent]);
}
我想在该提交中添加一个注释,并在以后获得所有这样的 repos 提交时能够检索
let repo = await Git.Repository.open(pathToSomewhere),
revWalk = repo.createRevWalk();
revWalk.sorting(Git.Revwalk.SORT.REVERSE);
revWalk.pushHead(); // places us at the last commit
let commits = await revWalk.getCommits();
let history = [];
for (let co = 0; co < commits.length; co++){
let commit = commits[co];
history.push({
sha: commit.sha(),
comment: commit.message(),
author: commit.author().toString(0),
date: commit.date()
});
}
我怎样才能做到这一点?
解决方案
推荐阅读
- pcap - LrWpanNetDevice NS3 中的混杂模式
- browser - Atom 编辑器 - 在浏览器中打开扩展 - 切换浏览器
- azure - 能否限制用户可以在 Azure Key Vault 中访问哪些密钥/机密?
- json - sql server 2016,JSON_VALUE 没有给出正确的值
- sql-server - 我的 Azure 托管 SQL Server 上的数据库枚举失败
- python - 如何检查我范围内的日期是否在包含日期列的 csv 文件中
- swift - 更改 UISegmentedControl 后如何重新加载 UIViewController
- javascript - React - 支付网关重定向后添加的查询参数消失
- branch.io - 链接域 branch.io
- c++ - 如何在 C++ 中追加到文件?