Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ crate-type = ["cdylib"]
bitflags = "2.1.0"
chrono = "0.4"
git2 = { version = "0.19.0", features = ["vendored-libgit2", "vendored-openssl"] }
napi = { version = "2.16.13", default-features = false, features = ["napi4", "chrono_date"] }
napi = { version = "2.16.13", default-features = false, features = ["napi6", "chrono_date"] }
napi-derive = "2.16.12"
serde = { version = "1", features = ["derive"] }
thiserror = "2.0.3"
Expand Down
310 changes: 310 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,193 @@

/* auto-generated by NAPI-RS */

export const enum DiffFlags {
/** File(s) treated as binary data. (1 << 0) */
Binary = 1,
/** File(s) treated as text data. (1 << 1) */
NotBinary = 2,
/** `id` value is known correct. (1 << 2) */
ValidId = 4,
/** File exists at this side of the delta. (1 << 3) */
Exists = 8
}
/** Check diff flags contains given flags. */
export declare function diffFlagsContains(source: number, target: number): boolean
/** What type of change is described by a `DiffDelta`? */
export type DeltaType = /** No changes */
'Unmodified' | /** Entry does not exist in old version */
'Added' | /** Entry does not exist in new version */
'Deleted' | /** Entry content changed between old and new */
'Modified' | /** Entry was renamed between old and new */
'Renamed' | /** Entry was copied from another old entry */
'Copied' | /** Entry is ignored item in workdir */
'Ignored' | /** Entry is untracked item in workdir */
'Untracked' | /** Type of entry changed between old and new */
'Typechange' | /** Entry is unreadable */
'Unreadable' | /** Entry in the index is conflicted */
'Conflicted';
/** Possible output formats for diff data */
export type DiffFormat = /** full git diff (default) */
'Patch' | /** just the headers of the patch */
'PatchHeader' | /** like git diff --raw */
'Raw' | /** like git diff --name-only */
'NameOnly' | /** like git diff --name-status */
'NameStatus' | /** git diff as used by git patch-id */
'PatchId';
export interface DiffPrintOptions {
format?: DiffFormat
}
/** Valid modes for index and tree entries. */
export type FileMode = 'Unreadable' | 'Tree' | 'Blob' | /** Group writable blob. Obsolete mode kept for compatibility reasons */
'BlobGroupWritable' | 'BlobExecutable' | 'Link' | 'Commit';
/** Structure describing options about how the diff should be executed. */
export interface DiffOptions {
/** Flag indicating whether the sides of the diff will be reversed. */
reverse?: boolean
/** Flag indicating whether ignored files are included. */
includeIgnored?: boolean
/** Flag indicating whether ignored directories are traversed deeply or not. */
recurseIgnoredDirs?: boolean
/** Flag indicating whether untracked files are in the diff */
includeUntracked?: boolean
/**
* Flag indicating whether untracked directories are traversed deeply or
* not.
*/
recurseUntrackedDirs?: boolean
/** Flag indicating whether unmodified files are in the diff. */
includeUnmodified?: boolean
/** If enabled, then Typechange delta records are generated. */
includeTypechange?: boolean
/**
* Event with `includeTypechange`, the tree returned generally shows a
* deleted blob. This flag correctly labels the tree transitions as a
* typechange record with the `new_file`'s mode set to tree.
*
* Note that the tree SHA will not be available.
*/
includeTypechangeTrees?: boolean
/** Flag indicating whether file mode changes are ignored. */
ignoreFilemode?: boolean
/** Flag indicating whether all submodules should be treated as unmodified. */
ignoreSubmodules?: boolean
/** Flag indicating whether case insensitive filenames should be used. */
ignoreCase?: boolean
/**
* If pathspecs are specified, this flag means that they should be applied
* as an exact match instead of a fnmatch pattern.
*/
disablePathspecMatch?: boolean
/**
* Disable updating the `binary` flag in delta records. This is useful when
* iterating over a diff if you don't need hunk and data callbacks and want
* to avoid having to load a file completely.
*/
skipBinaryCheck?: boolean
/**
* When diff finds an untracked directory, to match the behavior of core
* Git, it scans the contents for ignored and untracked files. If all
* contents are ignored, then the directory is ignored; if any contents are
* not ignored, then the directory is untracked. This is extra work that
* may not matter in many cases.
*
* This flag turns off that scan and immediately labels an untracked
* directory as untracked (changing the behavior to not match core git).
*/
enableFastUntrackedDirs?: boolean
/**
* When diff finds a file in the working directory with stat information
* different from the index, but the OID ends up being the same, write the
* correct stat information into the index. Note: without this flag, diff
* will always leave the index untouched.
*/
updateIndex?: boolean
/** Include unreadable files in the diff */
includeUnreadable?: boolean
/** Include unreadable files in the diff as untracked files */
includeUnreadableAsUntracked?: boolean
/** Treat all files as text, disabling binary attributes and detection. */
forceText?: boolean
/** Treat all files as binary, disabling text diffs */
forceBinary?: boolean
/** Ignore all whitespace */
ignoreWhitespace?: boolean
/** Ignore changes in the amount of whitespace */
ignoreWhitespaceChange?: boolean
/** Ignore whitespace at the end of line */
ignoreWhitespaceEol?: boolean
/** Ignore blank lines */
ignoreBlankLines?: boolean
/**
* When generating patch text, include the content of untracked files.
*
* This automatically turns on `includeUntracked` but it does not turn on
* `recurseUntrackedDirs`. Add that flag if you want the content of every
* single untracked file.
*/
showUntrackedContent?: boolean
/**
* When generating output, include the names of unmodified files if they
* are included in the `Diff`. Normally these are skipped in the formats
* that list files (e.g. name-only, name-status, raw). Even with this these
* will not be included in the patch format.
*/
showUnmodified?: boolean
/** Use the "patience diff" algorithm */
patience?: boolean
/** Take extra time to find the minimal diff */
minimal?: boolean
/**
* Include the necessary deflate/delta information so that `git-apply` can
* apply given diff information to binary files.
*/
showBinary?: boolean
/**
* Use a heuristic that takes indentation and whitespace into account
* which generally can produce better diffs when dealing with ambiguous
* diff hunks.
*/
indentHeuristic?: boolean
/**
* Set the number of unchanged lines that define the boundary of a hunk
* (and to display before and after).
*
* The default value for this is 3.
*/
contextLines?: number
/**
* Set the maximum number of unchanged lines between hunk boundaries before
* the hunks will be merged into one.
*
* The default value for this is 0.
*/
interhunkLines?: number
/** The default value for this is `core.abbrev` or 7 if unset. */
idAbbrev?: number
/**
* Maximum size (in bytes) above which a blob will be marked as binary
* automatically.
*
* A negative value will disable this entirely.
*
* The default value for this is 512MB.
*/
maxSize?: number
/**
* The virtual "directory" to prefix old file names with in hunk headers.
*
* The default value for this is "a".
*/
oldPrefix?: string
/**
* The virtual "directory" to prefix new file names with in hunk headers.
*
* The default value for this is "b".
*/
newPrefix?: string
/** Add to the array of paths/fnmatch patterns to constrain the diff. */
pathspecs?: Array<string>
}
export interface IndexEntry {
ctime: Date
mtime: Date
Expand Down Expand Up @@ -387,6 +574,7 @@ export interface FetchRemoteOptions {
export interface PruneOptions {
credential?: Credential
}
/** A listing of the possible states that a repository can be in. */
export type RepositoryState = 'Clean' | 'Merge' | 'Revert' | 'RevertSequence' | 'CherryPick' | 'CherryPickSequence' | 'Bisect' | 'Rebase' | 'RebaseInteractive' | 'RebaseMerge' | 'ApplyMailbox' | 'ApplyMailboxOrRebase';
export interface RepositoryInitOptions {
bare?: boolean
Expand Down Expand Up @@ -550,6 +738,105 @@ export declare class Commit {
*/
time(): Date
}
/**
* The diff object that contains all individual file deltas.
*
* This is an opaque structure which will be allocated by one of the diff
* generator functions on the `Repository` structure (e.g. `diff_tree_to_tree`
* or other `diff_*` functions).
*/
export declare class Diff {
/**
* Merge one diff into another.
*
* This merges items from the "from" list into the "self" list. The
* resulting diff will have all items that appear in either list.
* If an item appears in both lists, then it will be "merged" to appear
* as if the old version was from the "onto" list and the new version
* is from the "from" list (with the exception that if the item has a
* pending DELETE in the middle, then it will show as deleted).
*/
merge(diff: Diff): void
/** Returns an iterator over the deltas in this diff. */
deltas(): Deltas
/** Check if deltas are sorted case sensitively or insensitively. */
isSortedIcase(): boolean
/** Accumulate diff statistics for all patches. */
stats(): DiffStats
/** Iterate over a diff generating formatted text output. */
print(options?: DiffPrintOptions | undefined | null): string
}
/** Structure describing a hunk of a diff. */
export declare class DiffStats {
/** Get the total number of files changed in a diff. */
get filesChanged(): bigint
/** Get the total number of insertions in a diff */
get insertions(): bigint
/** Get the total number of deletions in a diff */
get deletions(): bigint
}
/** An iterator over the diffs in a delta */
export declare class Deltas {
[Symbol.iterator](): Iterator<DiffDelta, void, void>
}
/** Description of changes to one entry. */
export declare class DiffDelta {
/**
* Returns the flags on the delta.
*
* For more information, see `DiffFlags`'s documentation.
*/
flags(): number
/** Returns the number of files in this delta. */
numFiles(): number
/** Returns the status of this entry */
status(): DeltaType
/**
* Return the file which represents the "from" side of the diff.
*
* What side this means depends on the function that was used to generate
* the diff and will be documented on the function itself.
*/
oldFile(): DiffFile
/**
* Return the file which represents the "to" side of the diff.
*
* What side this means depends on the function that was used to generate
* the diff and will be documented on the function itself.
*/
newFile(): DiffFile
}
/**
* Description of one side of a delta.
*
* Although this is called a "file" it could represent a file, a symbolic
* link, a submodule commit id, or even a tree (although that only happens if
* you are tracking type changes or ignored/untracked directories).
*/
export declare class DiffFile {
/**
* Returns the Oid of this item.
*
* If this entry represents an absent side of a diff (e.g. the `old_file`
* of a `Added` delta), then the oid returned will be zeroes.
*/
id(): string
/**
* Returns the path of the entry relative to the working directory of the
* repository.
*/
path(): string | null
/** Returns the size of this entry, in bytes */
size(): bigint
/** Returns `true` if file(s) are treated as binary data. */
isBinary(): boolean
/** Returns `true` if `id` value is known correct. */
isValidId(): boolean
/** Returns `true` if file exists at this side of the delta. */
exists(): boolean
/** Returns file mode. */
mode(): FileMode
}
/**
* A structure to represent a git [index][1]
*
Expand Down Expand Up @@ -873,6 +1160,29 @@ export declare class Repository {
findCommit(oid: string): Commit | null
/** Lookup a reference to one of the commits in a repository. */
getCommit(oid: string): Commit
/**
* Create a diff between two index objects.
*
* The first index will be used for the "old_file" side of the delta, and
* the second index will be used for the "new_file" side of the delta.
*/
diffIndexToIndex(oldIndex: Index, newIndex: Index, options?: DiffOptions | undefined | null): Diff
/**
* Create a diff between the repository index and the workdir directory.
*
* This matches the `git diff` command. See the note below on
* `tree_to_workdir` for a discussion of the difference between
* `git diff` and `git diff HEAD` and how to emulate a `git diff <treeish>`
* using libgit2.
*
* The index will be used for the "old_file" side of the delta, and the
* working directory will be used for the "new_file" side of the delta.
*
* If you pass `None` for the index, then the existing index of the `repo`
* will be used. In this case, the index will be refreshed from disk
* (if it has changed) before the diff is generated.
*/
diffIndexToWorkdir(index?: Index | undefined | null, options?: DiffOptions | undefined | null): Diff
/**
* Get the Index file for this repository.
*
Expand Down
12 changes: 11 additions & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
},
"engines": {
"node": ">= 10"
"node": ">= 16"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

napi6 requires minimum Node.js 16 version

},
"scripts": {
"prepublishOnly": "napi prepublish -t npm",
Expand Down
Loading
Loading