getTree causes crash on commits created by fileHistoryWalk
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- git, javascript, node.js
- 领域
- devtools
调研方向
从 node_modules/nodegit/dist/commit.js 中所示的 getTree 实现开始,并在 issue 的 index.js 示例中通过 Revwalk.fileHistoryWalk 重现该故障。将失败的 entry.commit 与 Commit.lookup workaround 进行比较;当 getTree 可以直接作用于 fileHistoryWalk 返回的 commit 且不会崩溃时,即完成。
由索引模型根据 Issue 内容生成。
描述
System information
- node version: v14.17.4
- npm or yarn version: Yarn v1.22.11
- OS/version/architecture: Debian 10 Buster x86_64
- Applicable nodegit version: 0.27.0
Problem
The getTree commit class method crashes when the commit is created by fileHistoryWalk.
This is technically a duplicate of #1045 but that was all the way back in 2016 and this problem has yet to be resolved.
Output:
(node:16430) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getTree' of undefined
at Commit.getTree (/home/hampus/loltest/lmao/node_modules/nodegit/dist/commit.js:290:20)
at main (/home/hampus/loltest/lmao/index.js:16:34)
at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
at processPromiseRejections (internal/process/promises.js:247:11)
at processTicksAndRejections (internal/process/task_queues.js:96:32)
(node:16430) TypeError: Cannot read property 'getTree' of undefined
at Commit.getTree (/home/hampus/loltest/lmao/node_modules/nodegit/dist/commit.js:290:20)
at main (/home/hampus/loltest/lmao/index.js:16:34)
(node:16430) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)
at processPromiseRejections (internal/process/promises.js:249:13)
at processTicksAndRejections (internal/process/task_queues.js:96:32)
Recreating the bug
const nodegit = require("nodegit");
async function main() {
const repository = await nodegit.Repository.openBare("{ repository }");
const revw = nodegit.Revwalk.create(repository);
revw.pushHead();
const cnt = (await revw.getCommitsUntil(() => true)).length;
revw.pushHead();
const history = await revw.fileHistoryWalk("{ any file or folder }", cnt);
for(const entry of history) {
console.log(await entry.commit.getTree());
}
}
main();
Workaround
A simple workaround for this is to create a new commit instance from the entry commit's sha.
const commit = await Commit.lookup(repository, entry.commit.sha());
// This will work
console.log(await commit.getTree());
Solution
#1110
- 主要语言
- JavaScript
- 星标
- 5.8k
- 派生
- 704
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nodegit/nodegit 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 5/5 一周以上 新手友好度 25/100
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
avniproject/avni-client#2135 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
难度 2/5 1-3 小时 新手友好度 72/100
bevyengine/bevy-website#2595 ·
-
ecosystem wording
难度 1/5 1 小时以内 新手友好度 90/100
matrix-org/matrix.org#3649 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
vadimdemedes/ink#1029 ·