NODEGIT - 向特定提交添加注释以存储元数据

问题描述

我读过 git-notes 可用于将自定义信息(例如元数据)添加到特定提交,但我找不到如何使用 nodegit

目前我正在提交这样的 repo 并且它工作正常

        // 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,commitMessage,oid,[]);
        } else {
            let head = await Git.Reference.nametoId(repo,"HEAD");
            let parent = await repo.getCommit(head);

            await repo.createCommit("HEAD",[parent]);
        }

我想向该提交添加一个 Note 并且能够在我获得这样的所有 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()
            });
        }

我该怎么做?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)