微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。