getTree causes crash on commits created by fileHistoryWalk
まだ誰も着手していません。
評価
- 難易度
- 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 の回避策を比較します。fileHistoryWalk が返す commit に対して getTree が直接クラッシュせずに動作すれば完了です。
索引モデルが 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 25/100
nodegit/nodegit の issue をすべて見る
似ている issue
-
Edit: CW+ オープンchannels:edit check:passed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
idean3885/claude-ops-agent#521 ·
-
forespørsel 🥰 ikoner 🖼 nytt ✨
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
難易度 1/5 1時間未満 初心者へのやさしさ 85/100