Title: `getTree` fails on result of `commit.parent(0)` · Issue #1653 · nodegit/nodegit · GitHub
Open Graph Title: `getTree` fails on result of `commit.parent(0)` · Issue #1653 · nodegit/nodegit
X Title: `getTree` fails on result of `commit.parent(0)` · Issue #1653 · nodegit/nodegit
Description: System information node version: v8.12.0 yarn version: 1.5.1 OS/version/architecture: darwin/18.2.0/x64 Applicable nodegit version: nodegit@0.25.0-alpha.9 (also repros in 0.24.1 and 0.23.0) Repro Here's a repro that runs against the node...
Open Graph Description: System information node version: v8.12.0 yarn version: 1.5.1 OS/version/architecture: darwin/18.2.0/x64 Applicable nodegit version: nodegit@0.25.0-alpha.9 (also repros in 0.24.1 and 0.23.0) Repro H...
X Description: System information node version: v8.12.0 yarn version: 1.5.1 OS/version/architecture: darwin/18.2.0/x64 Applicable nodegit version: nodegit@0.25.0-alpha.9 (also repros in 0.24.1 and 0.23.0) Repro H...
Opengraph URL: https://github.com/nodegit/nodegit/issues/1653
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`getTree` fails on result of `commit.parent(0)`","articleBody":"## System information\r\n - node version: v8.12.0\r\n - yarn version: 1.5.1\r\n - OS/version/architecture: darwin/18.2.0/x64\r\n - Applicable nodegit version: nodegit@0.25.0-alpha.9 (also repros in 0.24.1 and 0.23.0)\r\n\r\n## Repro\r\n\r\nHere's a repro that runs against the `nodegit` git repo:\r\n\r\n```js\r\nconst nodegit = require('nodegit');\r\n\r\nnodegit.Repository.open('../nodegit').then(repo =\u003e {\r\n return repo.getCommit('977251b4aae52eef75cf4f188b4d5a63ba98fa7b')\r\n}).then(commit =\u003e {\r\n return commit.parent(0);\r\n}).then(parentCommit =\u003e {\r\n return parentCommit.getTree();\r\n}).then(parentTree =\u003e {\r\n console.log('parentTree: ' + parentTree);\r\n}).then(null, err =\u003e {\r\n console.log('Error encountered\\n');\r\n console.log(err);\r\n});\r\n```\r\n\r\n**Expected output:** `parentTree: [object Tree]`\r\n\r\n**Actual output:**\r\n\r\n```\r\nError encountered\r\n\r\nTypeError: Cannot read property 'getTree' of undefined\r\n at Commit.getTree (node_modules/nodegit/dist/commit.js:302:20)\r\n at nodegit.Repository.open.then.then.then.parentCommit (main.js:11:23)\r\n at tryCallOne (node_modules/nodegit-promise/lib/core.js:37:12)\r\n at node_modules/nodegit-promise/lib/core.js:103:15\r\n at flush (node_modules/asap/raw.js:50:29)\r\n at _combinedTickCallback (internal/process/next_tick.js:132:7)\r\n at process._tickCallback (internal/process/next_tick.js:181:9)\r\n```\r\n\r\nIt looks like [this line](https://github.com/nodegit/nodegit/blob/7851e931a54ca487fb6556ab8713c94ac1719efb/lib/commit.js#L352) throws an exception because `this.repo` is `undefined`.","author":{"url":"https://github.com/rigdern","@type":"Person","name":"rigdern"},"datePublished":"2019-03-31T16:57:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1653/nodegit/issues/1653"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ab5529ec-6bfc-253a-246b-a45195817876 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D250:FE136:346ACF4:352211D:697039B4 |
| html-safe-nonce | 8bfd7a0024708ccb39edb169efca5f16a15475b605b9b110c8eebf52d7c93cc5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjUwOkZFMTM2OjM0NkFDRjQ6MzUyMjExRDo2OTcwMzlCNCIsInZpc2l0b3JfaWQiOiI4MDg2NzA5MDEyNDU2ODE1MDI5IiwicmVnaW9uX2VkZ2UiOiJzZWEiLCJyZWdpb25fcmVuZGVyIjoic2VhIn0= |
| visitor-hmac | b3a6fd61e7af781f9546407607a3875f5b06fbaf0b5114a8380a408aedf1369b |
| hovercard-subject-tag | issue:427417997 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodegit/nodegit/1653/issue_layout |
| twitter:image | https://opengraph.githubassets.com/089680b5876b3d1cc18d3d8c3f99d6875904874383036828886a774aa751c9a4/nodegit/nodegit/issues/1653 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/089680b5876b3d1cc18d3d8c3f99d6875904874383036828886a774aa751c9a4/nodegit/nodegit/issues/1653 |
| og:image:alt | System information node version: v8.12.0 yarn version: 1.5.1 OS/version/architecture: darwin/18.2.0/x64 Applicable nodegit version: nodegit@0.25.0-alpha.9 (also repros in 0.24.1 and 0.23.0) Repro H... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rigdern |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodegit/nodegit git https://github.com/nodegit/nodegit.git |
| octolytics-dimension-user_id | 657068 |
| octolytics-dimension-user_login | nodegit |
| octolytics-dimension-repository_id | 1383170 |
| octolytics-dimension-repository_nwo | nodegit/nodegit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1383170 |
| octolytics-dimension-repository_network_root_nwo | nodegit/nodegit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f643964067a552f02067066d6a910b2f90a5721f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width