Skip to content

Migrate from NAN to Node API (N-API) to support other Node-compatible runtimes - #2043

Open
yumin-chen wants to merge 3 commits into
nodegit:masterfrom
Chen-Software:node-api
Open

yumin-chen wants to merge 3 commits into
nodegit:masterfrom
Chen-Software:node-api

Conversation

@yumin-chen

@yumin-chen yumin-chen commented Sep 21, 2026 •

Copy link
Copy Markdown

This PR migrates from NAN-based bindings to newer Node API (N-API) to support other Node-compatible runtimes such as Bun and Deno.

This PR is created with the assist of LLM but I've manually tested the build on my MacOS 12.7 x64 (Intel i7) and running with Node, Bun, Deno successfully on top of automated npm test.

npm test
npm notice run nodegit@0.28.0-alpha.38 test
npm notice run npm run lint && node --expose-gc test
npm notice run nodegit@0.28.0-alpha.38 lint
npm notice run jshint lib test/tests test/utils lifecycleScripts

AnnotatedCommit
✔ can create an AnnotatedCommit from a ref
✔ can lookup an AnnotatedCommit after creating it
✔ can lookup an AnnotatedCommit from a revspec
✔ can lookup an AnnotatedCommit from a fetchhead

Attr
✔ can add a macro definition
✔ can flush the attr cache
✔ can lookup the value of a git attribute

Blame
✔ can initialize blame without options

Blob
✔ can provide content as a buffer
✔ can provide content as a string
✔ can determine if a blob is not a binary
✔ can get a blob with an Oid object
createFromBuffer
✔ creates a new blob from the buffer
✔ creates blob with content equal to length
✔ throws an error when repository is null
✔ throws an error when buffer is null
✔ throws an error when no length is provided
createFromDisk
✔ creates a new blob from the file
✔ throws an error when the file cannot be found
✔ throws an error when repository is null
✔ throws an error when path is null
createFromWorkdir
✔ creates a blob from the file
✔ throws an error when the file cannot be found
✔ throws an error when repository is null
✔ throws an error when path is null
filteredContent (DEPRECATED)
(node:54255) DeprecationWarning: NodeGit.Blob.filteredContent is deprecated use NodeGit.Blob.prototype.filter instead.
(Use node --trace-deprecation ... to show where the warning was created)
✔ retrieves the filtered content (64ms)
✔ returns non-binary filtered content when checking binary
✔ returns nothing when checking binary blob
✔ returns blob when not checking binary on binary blob
✔ throws an error when the blob is null
✔ throws an error when the path is null
✔ throws an error when the flag is undefined
filter
✔ retrieves the filtered content
✔ returns non-binary filtered content when checking binary
✔ returns nothing when checking binary blob
✔ returns blob when not checking binary on binary blob
✔ throws an error when the path is null

Branch
✔ can create a branch
✔ can delete a branch
✔ can see if the branch is pointed to by head
✔ can set an upstream for a branch
✔ can get the name of a branch
✔ can get the remote name of a branch
✔ cannot get remote name from a non-remote branch
✔ can rename a branch
✔ can lookup a branch
✔ can create branch from annotated commit

Checkout
✔ can checkout the head
✔ can checkout a branch with a long file path
- cannot checkout long path file if core.longpaths is not set on win32
✔ can force checkout a single file
✔ can checkout by tree
✔ can checkout a branch
libc++abi: terminating with uncaught exception of type Napi::Error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant