Migrate from NAN to Node API (N-API) to support other Node-compatible runtimes - #2043
Open
yumin-chen wants to merge 3 commits into
Open
yumin-chen wants to merge 3 commits into
yumin-chen wants to merge 3 commits into
Conversation
Require node >= 22 and use NAPI_VERSION=10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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