isomorphic-git
Version:
A pure JavaScript reimplementation of git for node and browsers
1,375 lines • 183 kB
text/typescript
export const __esModule: boolean;
export default index;
export type TreeEntry = {
/**
* - the 6 digit hexadecimal mode
*/
mode: string;
/**
* - the name of the file or directory
*/
path: string;
/**
* - the SHA-1 object id of the blob or tree
*/
oid: string;
/**
* - the type of object
*/
type: "commit" | "blob" | "tree";
};
/**
* - The object returned has the following schema:
*/
export type ReadTreeResult = {
/**
* - SHA-1 object id of this tree
*/
oid: string;
/**
* - the parsed tree object
*/
tree: TreeObject;
};
/**
* - The object returned has the following schema:
*/
export type FetchResult = {
/**
* - The branch that is cloned if no branch is specified
*/
defaultBranch: string | null;
/**
* - The SHA-1 object id of the fetched head commit
*/
fetchHead: string | null;
/**
* - a textual description of the branch that was fetched
*/
fetchHeadDescription: string | null;
/**
* - The HTTP response headers returned by the git server
*/
headers?: {
[x: string]: string;
} | undefined;
/**
* - A list of branches that were pruned, if you provided the `prune` parameter
*/
pruned?: string[] | undefined;
};
/**
* - Returns an object with a schema like this:
*/
export type MergeResult = {
/**
* - The SHA-1 object id that is now at the head of the branch. Absent only if `dryRun` was specified and `mergeCommit` is true.
*/
oid?: string | undefined;
/**
* - True if the branch was already merged so no changes were made
*/
alreadyMerged?: boolean | undefined;
/**
* - True if it was a fast-forward merge
*/
fastForward?: boolean | undefined;
/**
* - True if merge resulted in a merge commit
*/
mergeCommit?: boolean | undefined;
/**
* - The SHA-1 object id of the tree resulting from a merge commit
*/
tree?: string | undefined;
};
/**
* - The object returned has the following schema:
*/
export type GetRemoteInfoResult = {
/**
* - The list of capabilities returned by the server (part of the Git protocol)
*/
capabilities: string[];
refs?: any;
/**
* - The default branch of the remote
*/
HEAD?: string | undefined;
/**
* - The branches on the remote
*/
heads?: {
[x: string]: string;
} | undefined;
/**
* - The special branches representing pull requests (non-standard)
*/
pull?: {
[x: string]: string;
} | undefined;
/**
* - The tags on the remote
*/
tags?: {
[x: string]: string;
} | undefined;
};
/**
* - This object has the following schema:
*/
export type GetRemoteInfo2Result = {
/**
* - Git protocol version the server supports
*/
protocolVersion: 1 | 2;
/**
* - An object of capabilities represented as keys and values
*/
capabilities: {
[x: string]: string | true;
};
/**
* - Server refs (they get returned by protocol version 1 whether you want them or not)
*/
refs?: ServerRef[] | undefined;
};
/**
* - The object returned has the following schema:
*/
export type HashBlobResult = {
/**
* - The SHA-1 object id
*/
oid: string;
/**
* - The type of the object
*/
type: "blob";
/**
* - The wrapped git object (the thing that is hashed)
*/
object: Uint8Array;
/**
* - The format of the object
*/
format: "wrapped";
};
/**
* - This object has the following schema:
*/
export type ServerRef = {
/**
* - The name of the ref
*/
ref: string;
/**
* - The SHA-1 object id the ref points to
*/
oid: string;
/**
* - The target ref pointed to by a symbolic ref
*/
target?: string | undefined;
/**
* - If the oid is the SHA-1 object id of an annotated tag, this is the SHA-1 object id that the annotated tag points to
*/
peeled?: string | undefined;
};
/**
* The packObjects command returns an object with two properties:
*/
export type PackObjectsResult = {
/**
* - The suggested filename for the packfile if you want to save it to disk somewhere. It includes the packfile SHA.
*/
filename: string;
/**
* - The packfile contents. Not present if `write` parameter was true, in which case the packfile was written straight to disk.
*/
packfile?: Uint8Array<ArrayBuffer> | undefined;
};
/**
* - The object returned has the following schema:
*/
export type ReadBlobResult = {
oid: string;
blob: Uint8Array;
};
export type DeflatedObject = {
oid: string;
type: "deflated";
format: "deflated";
object: Uint8Array;
source?: string | undefined;
};
export type WrappedObject = {
oid: string;
type: "wrapped";
format: "wrapped";
object: Uint8Array;
source?: string | undefined;
};
export type RawObject = {
oid: string;
type: "blob" | "commit" | "tree" | "tag";
format: "content";
object: Uint8Array;
source?: string | undefined;
};
export type ParsedBlobObject = {
oid: string;
type: "blob";
format: "parsed";
object: string;
source?: string | undefined;
};
export type ParsedCommitObject = {
oid: string;
type: "commit";
format: "parsed";
object: CommitObject;
source?: string | undefined;
};
export type ParsedTreeObject = {
oid: string;
type: "tree";
format: "parsed";
object: TreeObject;
source?: string | undefined;
};
export type ParsedTagObject = {
oid: string;
type: "tag";
format: "parsed";
object: TagObject;
source?: string | undefined;
};
export type ParsedObject = ParsedBlobObject | ParsedCommitObject | ParsedTreeObject | ParsedTagObject;
export type ReadObjectResult = DeflatedObject | WrappedObject | RawObject | ParsedObject;
/**
* - The object returned has the following schema:
*/
export type ReadTagResult = {
/**
* - SHA-1 object id of this tag
*/
oid: string;
/**
* - the parsed tag object
*/
tag: TagObject;
/**
* - PGP signing payload
*/
payload: string;
};
export type WalkerMap = (filename: string, entries: Array<WalkerEntry | null>) => Promise<any>;
export type WalkerReduce = (parent: any, children: any[]) => Promise<any>;
export type WalkerIterateCallback = (entries: WalkerEntry[]) => Promise<any[]>;
export type WalkerIterate = (walk: WalkerIterateCallback, children: IterableIterator<WalkerEntry[]>) => Promise<any[]>;
export type GitProgressEvent = {
phase: string;
loaded: number;
total: number;
};
export type ProgressCallback = (progress: GitProgressEvent) => void | Promise<void>;
export type GitHttpRequest = {
/**
* - The URL to request
*/
url: string;
/**
* - The HTTP method to use
*/
method?: string | undefined;
/**
* - Headers to include in the HTTP request
*/
headers?: {
[x: string]: string;
} | undefined;
/**
* - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
*/
agent?: any;
/**
* - An async iterator of Uint8Arrays that make up the body of POST requests
*/
body?: AsyncIterableIterator<Uint8Array>;
/**
* - Reserved for future use (emitting `GitProgressEvent`s)
*/
onProgress?: ProgressCallback | undefined;
/**
* - Reserved for future use (canceling a request)
*/
signal?: object;
};
export type GitHttpResponse = {
/**
* - The final URL that was fetched after any redirects
*/
url: string;
/**
* - The HTTP method that was used
*/
method?: string | undefined;
/**
* - HTTP response headers
*/
headers?: {
[x: string]: string;
} | undefined;
/**
* - An async iterator of Uint8Arrays that make up the body of the response
*/
body?: AsyncIterableIterator<Uint8Array>;
/**
* - The HTTP status code
*/
statusCode: number;
/**
* - The HTTP status message
*/
statusMessage: string;
};
export type HttpFetch = (request: GitHttpRequest) => Promise<GitHttpResponse>;
export type HttpClient = {
request: HttpFetch;
};
/**
* A git commit object.
*/
export type CommitObject = {
/**
* Commit message
*/
message: string;
/**
* SHA-1 object id of corresponding file tree
*/
tree: string;
/**
* an array of zero or more SHA-1 object ids
*/
parent: string[];
author: {
name: string;
email: string;
timestamp: number;
timezoneOffset: number;
};
committer: {
name: string;
email: string;
timestamp: number;
timezoneOffset: number;
};
/**
* PGP signature (if present)
*/
gpgsig?: string | undefined;
};
/**
* A git tree object. Trees represent a directory snapshot.
*/
export type TreeObject = TreeEntry[];
/**
* A git annotated tag object.
*/
export type TagObject = {
/**
* SHA-1 object id of object being tagged
*/
object: string;
/**
* the type of the object being tagged
*/
type: "blob" | "tree" | "commit" | "tag";
/**
* the tag name
*/
tag: string;
tagger: {
name: string;
email: string;
timestamp: number;
timezoneOffset: number;
};
/**
* tag message
*/
message: string;
/**
* PGP signature (if present)
*/
gpgsig?: string | undefined;
};
export type ReadCommitResult = {
/**
* - SHA-1 object id of this commit
*/
oid: string;
/**
* - the parsed commit object
*/
commit: CommitObject;
/**
* - PGP signing payload
*/
payload: string;
};
export type Walker = {
/**
* ('GitWalkerSymbol')
*/
Symbol: Symbol;
};
/**
* Normalized subset of filesystem `stat` data:
*/
export type Stat = {
ctimeSeconds: number;
ctimeNanoseconds: number;
mtimeSeconds: number;
mtimeNanoseconds: number;
dev: number;
ino: number;
mode: number;
uid: number;
gid: number;
size: number;
};
/**
* The `WalkerEntry` is an interface that abstracts computing many common tree / blob stats.
*/
export type WalkerEntry = {
type: () => Promise<"tree" | "blob" | "special" | "commit">;
mode: () => Promise<number>;
oid: () => Promise<string>;
content: () => Promise<Uint8Array | void>;
stat: () => Promise<Stat>;
};
export type CallbackFsClient = {
/**
* - https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback
*/
readFile: Function;
/**
* - https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback
*/
writeFile: Function;
/**
* - https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback
*/
unlink: Function;
/**
* - https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback
*/
readdir: Function;
/**
* - https://nodejs.org/api/fs.html#fs_fs_mkdir_path_mode_callback
*/
mkdir: Function;
/**
* - https://nodejs.org/api/fs.html#fs_fs_rmdir_path_callback
*/
rmdir: Function;
/**
* - https://nodejs.org/api/fs.html#fs_fs_stat_path_options_callback
*/
stat: Function;
/**
* - https://nodejs.org/api/fs.html#fs_fs_lstat_path_options_callback
*/
lstat: Function;
/**
* - https://nodejs.org/api/fs.html#fs_fs_readlink_path_options_callback
*/
readlink?: Function | undefined;
/**
* - https://nodejs.org/api/fs.html#fs_fs_symlink_target_path_type_callback
*/
symlink?: Function | undefined;
/**
* - https://nodejs.org/api/fs.html#fs_fs_chmod_path_mode_callback
*/
chmod?: Function | undefined;
};
export type PromiseFsClient = {
promises: {
readFile: Function;
writeFile: Function;
unlink: Function;
readdir: Function;
mkdir: Function;
rmdir: Function;
stat: Function;
lstat: Function;
readlink?: Function | undefined;
symlink?: Function | undefined;
chmod?: Function | undefined;
};
};
export type FsClient = CallbackFsClient | PromiseFsClient;
export type MessageCallback = (message: string) => void | Promise<void>;
export type GitAuth = {
username?: string | undefined;
password?: string | undefined;
headers?: {
[x: string]: string;
} | undefined;
/**
* Tells git to throw a `UserCanceledError` (instead of an `HttpError`).
*/
cancel?: boolean | undefined;
};
export type AuthCallback = (url: string, auth: GitAuth) => GitAuth | void | Promise<GitAuth | void>;
export type AuthFailureCallback = (url: string, auth: GitAuth) => GitAuth | void | Promise<GitAuth | void>;
export type AuthSuccessCallback = (url: string, auth: GitAuth) => void | Promise<void>;
export type SignParams = {
/**
* - a plaintext message
*/
payload: string;
/**
* - an 'ASCII armor' encoded PGP key (technically can actually contain _multiple_ keys)
*/
secretKey: string;
};
export type SignCallback = (args: SignParams) => {
signature: string;
} | Promise<{
signature: string;
}>;
export type MergeDriverParams = {
branches: Array<string>;
contents: Array<string>;
path: string;
};
export type MergeDriverCallback = (args: MergeDriverParams) => {
cleanMerge: boolean;
mergedText: string;
} | Promise<{
cleanMerge: boolean;
mergedText: string;
}>;
export type RefUpdateStatus = {
ok: boolean;
error: string;
};
export type PushResult = {
ok: boolean;
error: string | null;
refs: {
[x: string]: RefUpdateStatus;
};
headers?: {
[x: string]: string;
} | undefined;
};
export type HeadStatus = 0 | 1;
export type WorkdirStatus = 0 | 1 | 2;
export type StageStatus = 0 | 1 | 2 | 3;
export type StatusRow = [string, HeadStatus, WorkdirStatus, StageStatus];
/**
* the type of stash ops
*/
export type StashOp = "push" | "pop" | "apply" | "drop" | "list" | "clear";
/**
* - when compare WORDIR to HEAD, 'remove' could mean 'untracked'
*/
export type StashChangeType = "equal" | "modify" | "add" | "remove" | "unknown";
export type ClientRef = {
/**
* The name of the ref
*/
ref: string;
/**
* The SHA-1 object id the ref points to
*/
oid: string;
};
export type PrePushParams = {
/**
* The expanded name of target remote
*/
remote: string;
/**
* The URL address of target remote
*/
url: string;
/**
* The ref which the client wants to push to the remote
*/
localRef: ClientRef;
/**
* The ref which is known by the remote
*/
remoteRef: ClientRef;
};
export type PrePushCallback = (args: PrePushParams) => boolean | Promise<boolean>;
export type PostCheckoutParams = {
/**
* The SHA-1 object id of HEAD before checkout
*/
previousHead: string;
/**
* The SHA-1 object id of HEAD after checkout
*/
newHead: string;
/**
* flag determining whether a branch or a set of files was checked
*/
type: "branch" | "file";
};
export type PostCheckoutCallback = (args: PostCheckoutParams) => void | Promise<void>;
export var Errors: Readonly<{
__proto__: null;
AlreadyExistsError: typeof AlreadyExistsError;
AmbiguousError: typeof AmbiguousError;
CheckoutConflictError: typeof CheckoutConflictError;
CommitNotFetchedError: typeof CommitNotFetchedError;
EmptyServerResponseError: typeof EmptyServerResponseError;
FastForwardError: typeof FastForwardError;
GitPushError: typeof GitPushError;
HttpError: typeof HttpError;
InternalError: typeof InternalError;
InvalidFilepathError: typeof InvalidFilepathError;
InvalidOidError: typeof InvalidOidError;
InvalidRefNameError: typeof InvalidRefNameError;
MaxDepthError: typeof MaxDepthError;
MergeNotSupportedError: typeof MergeNotSupportedError;
MergeConflictError: typeof MergeConflictError;
MissingNameError: typeof MissingNameError;
MissingParameterError: typeof MissingParameterError;
MultipleGitError: typeof MultipleGitError;
NoRefspecError: typeof NoRefspecError;
NotFoundError: typeof NotFoundError;
ObjectTypeError: typeof ObjectTypeError;
ParseError: typeof ParseError;
PushRejectedError: typeof PushRejectedError;
RemoteCapabilityError: typeof RemoteCapabilityError;
SmartHttpError: typeof SmartHttpError;
UnknownTransportError: typeof UnknownTransportError;
UnsafeFilepathError: typeof UnsafeFilepathError;
UrlParseError: typeof UrlParseError;
UserCanceledError: typeof UserCanceledError;
UnmergedPathsError: typeof UnmergedPathsError;
IndexResetError: typeof IndexResetError;
NoCommitError: typeof NoCommitError;
}>;
/**
* @returns {Walker}
*/
export function STAGE(): Walker;
/**
* @param {object} args
* @param {string} [args.ref='HEAD']
* @returns {Walker}
*/
export function TREE({ ref }?: {
ref?: string | undefined;
}): Walker;
/**
* @returns {Walker}
*/
export function WORKDIR(): Walker;
/**
* Abort a merge in progress.
*
* Based on the behavior of git reset --merge, i.e. "Resets the index and updates the files in the working tree that are different between <commit> and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between <commit> and the index has unstaged changes, reset is aborted."
*
* Essentially, abortMerge will reset any files affected by merge conflicts to their last known good version at HEAD.
* Any unstaged changes are saved and any staged changes are reset as well.
*
* NOTE: The behavior of this command differs slightly from canonical git in that an error will be thrown if a file exists in the index and nowhere else.
* Canonical git will reset the file and continue aborting the merge in this case.
*
* **WARNING:** Running git merge with non-trivial uncommitted changes is discouraged: while possible, it may leave you in a state that is hard to back out of in the case of a conflict.
* If there were uncommitted changes when the merge started (and especially if those changes were further modified after the merge was started), `git.abortMerge` will in some cases be unable to reconstruct the original (pre-merge) changes.
*
* @param {object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} [args.commit='HEAD'] - commit to reset the index and worktree to, defaults to HEAD
* @param {object} [args.cache] - a [cache](cache.md) object
*
* @returns {Promise<void>} Resolves successfully once the git index has been updated
*
*/
export function abortMerge({ fs: _fs, dir, gitdir, commit, cache, }: {
fs: FsClient;
dir: string;
gitdir?: string | undefined;
commit?: string | undefined;
cache?: object;
}): Promise<void>;
/**
* Add a file to the git index (aka staging area)
*
* @param {object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string|string[]} args.filepath - The path to the file to add to the index
* @param {object} [args.cache] - a [cache](cache.md) object
* @param {boolean} [args.force=false] - add to index even if matches gitignore. Think `git add --force`
* @param {boolean} [args.parallel=false] - process each input file in parallel. Parallel processing will result in more memory consumption but less process time
*
* @returns {Promise<void>} Resolves successfully once the git index has been updated
*
* @example
* await fs.promises.writeFile('/tutorial/README.md', `# TEST`)
* await git.add({ fs, dir: '/tutorial', filepath: 'README.md' })
* console.log('done')
*
*/
export function add({ fs: _fs, dir, gitdir, filepath, cache, force, parallel, }: {
fs: FsClient;
dir: string;
gitdir?: string | undefined;
filepath: string | string[];
cache?: object;
force?: boolean | undefined;
parallel?: boolean | undefined;
}): Promise<void>;
/**
* Add or update an object note
*
* @param {object} args
* @param {FsClient} args.fs - a file system implementation
* @param {SignCallback} [args.onSign] - a PGP signing implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} [args.ref] - The notes ref to look under
* @param {string} args.oid - The SHA-1 object id of the object to add the note to.
* @param {string|Uint8Array} args.note - The note to add
* @param {boolean} [args.force] - Over-write note if it already exists.
* @param {Object} [args.author] - The details about the author.
* @param {string} [args.author.name] - Default is `user.name` config.
* @param {string} [args.author.email] - Default is `user.email` config.
* @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
* @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
* @param {Object} [args.committer = author] - The details about the note committer, in the same format as the author parameter. If not specified, the author details are used.
* @param {string} [args.committer.name] - Default is `user.name` config.
* @param {string} [args.committer.email] - Default is `user.email` config.
* @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
* @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
* @param {string} [args.signingKey] - Sign the note commit using this private PGP key.
* @param {object} [args.cache] - a [cache](cache.md) object
*
* @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the commit object for the added note.
*/
export function addNote({ fs: _fs, onSign, dir, gitdir, ref, oid, note, force, author: _author, committer: _committer, signingKey, cache, }: {
fs: FsClient;
onSign?: SignCallback | undefined;
dir?: string | undefined;
gitdir?: string | undefined;
ref?: string | undefined;
oid: string;
note: string | Uint8Array;
force?: boolean | undefined;
author?: {
name?: string | undefined;
email?: string | undefined;
timestamp?: number | undefined;
timezoneOffset?: number | undefined;
} | undefined;
committer?: {
name?: string | undefined;
email?: string | undefined;
timestamp?: number | undefined;
timezoneOffset?: number | undefined;
} | undefined;
signingKey?: string | undefined;
cache?: object;
}): Promise<string>;
/**
* Add or update a remote
*
* @param {object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} args.remote - The name of the remote
* @param {string} args.url - The URL of the remote
* @param {boolean} [args.force = false] - Instead of throwing an error if a remote named `remote` already exists, overwrite the existing remote.
*
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
*
* @example
* await git.addRemote({
* fs,
* dir: '/tutorial',
* remote: 'upstream',
* url: 'https://github.com/isomorphic-git/isomorphic-git'
* })
* console.log('done')
*
*/
export function addRemote({ fs, dir, gitdir, remote, url, force, }: {
fs: FsClient;
dir?: string | undefined;
gitdir?: string | undefined;
remote: string;
url: string;
force?: boolean | undefined;
}): Promise<void>;
/**
* Create an annotated tag.
*
* @param {object} args
* @param {FsClient} args.fs - a file system implementation
* @param {SignCallback} [args.onSign] - a PGP signing implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} args.ref - What to name the tag
* @param {string} [args.message = ref] - The tag message to use.
* @param {string} [args.object = 'HEAD'] - The SHA-1 object id the tag points to. (Will resolve to a SHA-1 object id if value is a ref.) By default, the commit object which is referred by the current `HEAD` is used.
* @param {object} [args.tagger] - The details about the tagger.
* @param {string} [args.tagger.name] - Default is `user.name` config.
* @param {string} [args.tagger.email] - Default is `user.email` config.
* @param {number} [args.tagger.timestamp=Math.floor(Date.now()/1000)] - Set the tagger timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
* @param {number} [args.tagger.timezoneOffset] - Set the tagger timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
* @param {string} [args.gpgsig] - The gpgsig attached to the tag object. (Mutually exclusive with the `signingKey` option.)
* @param {string} [args.signingKey] - Sign the tag object using this private PGP key. (Mutually exclusive with the `gpgsig` option.)
* @param {boolean} [args.force = false] - Instead of throwing an error if a tag named `ref` already exists, overwrite the existing tag. Note that this option does not modify the original tag object itself.
* @param {object} [args.cache] - a [cache](cache.md) object
*
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
*
* @example
* await git.annotatedTag({
* fs,
* dir: '/tutorial',
* ref: 'test-tag',
* message: 'This commit is awesome',
* tagger: {
* name: 'Mr. Test',
* email: 'mrtest@example.com'
* }
* })
* console.log('done')
*
*/
export function annotatedTag({ fs: _fs, onSign, dir, gitdir, ref, tagger: _tagger, message, gpgsig, object, signingKey, force, cache, }: {
fs: FsClient;
onSign?: SignCallback | undefined;
dir?: string | undefined;
gitdir?: string | undefined;
ref: string;
message?: string | undefined;
object?: string | undefined;
tagger?: {
name?: string | undefined;
email?: string | undefined;
timestamp?: number | undefined;
timezoneOffset?: number | undefined;
} | undefined;
gpgsig?: string | undefined;
signingKey?: string | undefined;
force?: boolean | undefined;
cache?: object;
}): Promise<void>;
/**
* Create a branch
*
* @param {object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} args.ref - What to name the branch
* @param {string} [args.object = 'HEAD'] - What oid to use as the start point. Accepts a symbolic ref.
* @param {boolean} [args.checkout = false] - Update `HEAD` to point at the newly created branch
* @param {boolean} [args.force = false] - Instead of throwing an error if a branched named `ref` already exists, overwrite the existing branch.
*
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
*
* @example
* await git.branch({ fs, dir: '/tutorial', ref: 'develop' })
* console.log('done')
*
*/
export function branch({ fs, dir, gitdir, ref, object, checkout, force, }: {
fs: FsClient;
dir?: string | undefined;
gitdir?: string | undefined;
ref: string;
object?: string | undefined;
checkout?: boolean | undefined;
force?: boolean | undefined;
}): Promise<void>;
/**
* Checkout a branch
*
* If the branch already exists it will check out that branch. Otherwise, it will create a new remote tracking branch set to track the remote branch of that name.
*
* @param {object} args
* @param {FsClient} args.fs - a file system implementation
* @param {ProgressCallback} [args.onProgress] - optional progress event callback
* @param {PostCheckoutCallback} [args.onPostCheckout] - optional post-checkout hook callback
* @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} [args.ref = 'HEAD'] - Source to checkout files from
* @param {string[]} [args.filepaths] - Limit the checkout to the given files and directories
* @param {string} [args.remote = 'origin'] - Which remote repository to use
* @param {boolean} [args.noCheckout = false] - If true, will update HEAD but won't update the working directory
* @param {boolean} [args.noUpdateHead] - If true, will update the working directory but won't update HEAD. Defaults to `false` when `ref` is provided, and `true` if `ref` is not provided.
* @param {boolean} [args.dryRun = false] - If true, simulates a checkout so you can test whether it would succeed.
* @param {boolean} [args.force = false] - If true, conflicts will be ignored and files will be overwritten regardless of local changes.
* @param {boolean} [args.track = true] - If false, will not set the remote branch tracking information. Defaults to true.
* @param {object} [args.cache] - a [cache](cache.md) object
* @param {boolean} [args.nonBlocking = false] - If true, will use non-blocking file system operations to allow for better performance in certain environments (For example, in Browsers)
* @param {number} [args.batchSize = 100] - If args.nonBlocking is true, batchSize is the number of files to process at a time avoid blocking the executing thread. The default value of 100 is a good starting point.
*
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
*
* @example
* // switch to the main branch
* await git.checkout({
* fs,
* dir: '/tutorial',
* ref: 'main'
* })
* console.log('done')
*
* @example
* // restore the 'docs' and 'src/docs' folders to the way they were, overwriting any changes
* await git.checkout({
* fs,
* dir: '/tutorial',
* force: true,
* filepaths: ['docs', 'src/docs']
* })
* console.log('done')
*
* @example
* // restore the 'docs' and 'src/docs' folders to the way they are in the 'develop' branch, overwriting any changes
* await git.checkout({
* fs,
* dir: '/tutorial',
* ref: 'develop',
* noUpdateHead: true,
* force: true,
* filepaths: ['docs', 'src/docs']
* })
* console.log('done')
*/
export function checkout({ fs, onProgress, onPostCheckout, dir, gitdir, remote, ref: _ref, filepaths, noCheckout, noUpdateHead, dryRun, force, track, cache, nonBlocking, batchSize, }: {
fs: FsClient;
onProgress?: ProgressCallback | undefined;
onPostCheckout?: PostCheckoutCallback | undefined;
dir: string;
gitdir?: string | undefined;
ref?: string | undefined;
filepaths?: string[] | undefined;
remote?: string | undefined;
noCheckout?: boolean | undefined;
noUpdateHead?: boolean | undefined;
dryRun?: boolean | undefined;
force?: boolean | undefined;
track?: boolean | undefined;
cache?: object;
nonBlocking?: boolean | undefined;
batchSize?: number | undefined;
}): Promise<void>;
/**
* Clone a repository
*
* @param {object} args
* @param {FsClient} args.fs - a file system implementation
* @param {HttpClient} args.http - an HTTP client
* @param {ProgressCallback} [args.onProgress] - optional progress event callback
* @param {MessageCallback} [args.onMessage] - optional message event callback
* @param {AuthCallback} [args.onAuth] - optional auth fill callback
* @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
* @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
* @param {PostCheckoutCallback} [args.onPostCheckout] - optional post-checkout hook callback
* @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} args.url - The URL of the remote repository
* @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Value is stored in the git config file for that repo.
* @param {string} [args.ref] - Which branch to checkout. By default this is the designated "main branch" of the repository.
* @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.
* @param {boolean} [args.noCheckout = false] - If true, clone will only fetch the repo, not check out a branch. Skipping checkout can save a lot of time normally spent writing files to disk.
* @param {boolean} [args.noTags = false] - By default clone will fetch all tags. `noTags` disables that behavior.
* @param {string} [args.remote = 'origin'] - What to name the remote that is created.
* @param {number} [args.depth] - Integer. Determines how much of the git repository's history to retrieve
* @param {Date} [args.since] - Only fetch commits created after the given date. Mutually exclusive with `depth`.
* @param {string[]} [args.exclude = []] - A list of branches or tags. Instructs the remote server not to send us any commits reachable from these refs.
* @param {boolean} [args.relative = false] - Changes the meaning of `depth` to be measured from the current shallow depth rather than from the branch tip.
* @param {Object<string, string>} [args.headers = {}] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
* @param {object} [args.cache] - a [cache](cache.md) object
* @param {boolean} [args.nonBlocking = false] - if true, checkout will happen non-blockingly (useful for long-running operations blocking the thread in browser environments)
* @param {number} [args.batchSize = 100] - If args.nonBlocking is true, batchSize is the number of files to process at a time avoid blocking the executing thread. The default value of 100 is a good starting point.
*
* @returns {Promise<void>} Resolves successfully when clone completes
*
* @example
* await git.clone({
* fs,
* http,
* dir: '/tutorial',
* corsProxy: 'https://cors.isomorphic-git.org',
* url: 'https://github.com/isomorphic-git/isomorphic-git',
* singleBranch: true,
* depth: 1
* })
* console.log('done')
*
*/
export function clone({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, onPostCheckout, dir, gitdir, url, corsProxy, ref, remote, depth, since, exclude, relative, singleBranch, noCheckout, noTags, headers, cache, nonBlocking, batchSize, }: {
fs: FsClient;
http: HttpClient;
onProgress?: ProgressCallback | undefined;
onMessage?: MessageCallback | undefined;
onAuth?: AuthCallback | undefined;
onAuthFailure?: AuthFailureCallback | undefined;
onAuthSuccess?: AuthSuccessCallback | undefined;
onPostCheckout?: PostCheckoutCallback | undefined;
dir: string;
gitdir?: string | undefined;
url: string;
corsProxy?: string | undefined;
ref?: string | undefined;
singleBranch?: boolean | undefined;
noCheckout?: boolean | undefined;
noTags?: boolean | undefined;
remote?: string | undefined;
depth?: number | undefined;
since?: Date | undefined;
exclude?: string[] | undefined;
relative?: boolean | undefined;
headers?: {
[x: string]: string;
} | undefined;
cache?: object;
nonBlocking?: boolean | undefined;
batchSize?: number | undefined;
}): Promise<void>;
/**
* Create a new commit
*
* @param {Object} args
* @param {FsClient} args.fs - a file system implementation
* @param {SignCallback} [args.onSign] - a PGP signing implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} [args.message] - The commit message to use. Required, unless `amend === true`
* @param {Object} [args.author] - The details about the author.
* @param {string} [args.author.name] - Default is `user.name` config.
* @param {string} [args.author.email] - Default is `user.email` config.
* @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
* @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
* @param {Object} [args.committer = author] - The details about the commit committer, in the same format as the author parameter. If not specified, the author details are used.
* @param {string} [args.committer.name] - Default is `user.name` config.
* @param {string} [args.committer.email] - Default is `user.email` config.
* @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
* @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
* @param {string} [args.signingKey] - Sign the tag object using this private PGP key.
* @param {boolean} [args.amend = false] - If true, replaces the last commit pointed to by `ref` with a new commit.
* @param {boolean} [args.dryRun = false] - If true, simulates making a commit so you can test whether it would succeed. Implies `noUpdateBranch`.
* @param {boolean} [args.noUpdateBranch = false] - If true, does not update the branch pointer after creating the commit.
* @param {string} [args.ref] - The fully expanded name of the branch to commit to. Default is the current branch pointed to by HEAD. (TODO: fix it so it can expand branch names without throwing if the branch doesn't exist yet.)
* @param {string[]} [args.parent] - The SHA-1 object ids of the commits to use as parents. If not specified, the commit pointed to by `ref` is used.
* @param {string} [args.tree] - The SHA-1 object id of the tree to use. If not specified, a new tree object is created from the current git index.
* @param {object} [args.cache] - a [cache](cache.md) object
*
* @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly created commit.
*
* @example
* let sha = await git.commit({
* fs,
* dir: '/tutorial',
* author: {
* name: 'Mr. Test',
* email: 'mrtest@example.com',
* },
* message: 'Added the a.txt file'
* })
* console.log(sha)
*
*/
export function commit({ fs: _fs, onSign, dir, gitdir, message, author, committer, signingKey, amend, dryRun, noUpdateBranch, ref, parent, tree, cache, }: {
fs: FsClient;
onSign?: SignCallback | undefined;
dir?: string | undefined;
gitdir?: string | undefined;
message?: string | undefined;
author?: {
name?: string | undefined;
email?: string | undefined;
timestamp?: number | undefined;
timezoneOffset?: number | undefined;
} | undefined;
committer?: {
name?: string | undefined;
email?: string | undefined;
timestamp?: number | undefined;
timezoneOffset?: number | undefined;
} | undefined;
signingKey?: string | undefined;
amend?: boolean | undefined;
dryRun?: boolean | undefined;
noUpdateBranch?: boolean | undefined;
ref?: string | undefined;
parent?: string[] | undefined;
tree?: string | undefined;
cache?: object;
}): Promise<string>;
/**
* Get the name of the branch currently pointed to by .git/HEAD
*
* @param {Object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {boolean} [args.fullname = false] - Return the full path (e.g. "refs/heads/main") instead of the abbreviated form.
* @param {boolean} [args.test = false] - If the current branch doesn't actually exist (such as right after git init) then return `undefined`.
*
* @returns {Promise<string|void>} The name of the current branch or undefined if the HEAD is detached.
*
* @example
* // Get the current branch name
* let branch = await git.currentBranch({
* fs,
* dir: '/tutorial',
* fullname: false
* })
* console.log(branch)
*
*/
export function currentBranch({ fs, dir, gitdir, fullname, test, }: {
fs: FsClient;
dir?: string | undefined;
gitdir?: string | undefined;
fullname?: boolean | undefined;
test?: boolean | undefined;
}): Promise<string | void>;
declare namespace index {
export { Errors };
export { STAGE };
export { TREE };
export { WORKDIR };
export { add };
export { abortMerge };
export { addNote };
export { addRemote };
export { annotatedTag };
export { branch };
export { checkout };
export { clone };
export { commit };
export { getConfig };
export { getConfigAll };
export { setConfig };
export { currentBranch };
export { deleteBranch };
export { deleteRef };
export { deleteRemote };
export { deleteTag };
export { expandOid };
export { expandRef };
export { fastForward };
export { fetch };
export { findMergeBase };
export { findRoot };
export { getRemoteInfo };
export { getRemoteInfo2 };
export { hashBlob };
export { indexPack };
export { init };
export { isDescendent };
export { isIgnored };
export { listBranches };
export { listFiles };
export { listNotes };
export { listRefs };
export { listRemotes };
export { listServerRefs };
export { listTags };
export { log };
export { merge };
export { packObjects };
export { pull };
export { push };
export { readBlob };
export { readCommit };
export { readNote };
export { readObject };
export { readTag };
export { readTree };
export { remove };
export { removeNote };
export { renameBranch };
export { resetIndex };
export { updateIndex$1 as updateIndex };
export { resolveRef };
export { status };
export { statusMatrix };
export { tag };
export { version };
export { walk };
export { writeBlob };
export { writeCommit };
export { writeObject };
export { writeRef };
export { writeTag };
export { writeTree };
export { stash };
}
/**
* Delete a local branch
*
* > Note: This only deletes loose branches - it should be fixed in the future to delete packed branches as well.
*
* @param {Object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} args.ref - The branch to delete
*
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
*
* @example
* await git.deleteBranch({ fs, dir: '/tutorial', ref: 'local-branch' })
* console.log('done')
*
*/
export function deleteBranch({ fs, dir, gitdir, ref, }: {
fs: FsClient;
dir?: string | undefined;
gitdir?: string | undefined;
ref: string;
}): Promise<void>;
/**
* Delete a local ref
*
* @param {Object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} args.ref - The ref to delete
*
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
*
* @example
* await git.deleteRef({ fs, dir: '/tutorial', ref: 'refs/tags/test-tag' })
* console.log('done')
*
*/
export function deleteRef({ fs, dir, gitdir, ref }: {
fs: FsClient;
dir?: string | undefined;
gitdir?: string | undefined;
ref: string;
}): Promise<void>;
/**
* Removes the local config entry for a given remote
*
* @param {Object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} args.remote - The name of the remote to delete
*
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
*
* @example
* await git.deleteRemote({ fs, dir: '/tutorial', remote: 'upstream' })
* console.log('done')
*
*/
export function deleteRemote({ fs, dir, gitdir, remote, }: {
fs: FsClient;
dir?: string | undefined;
gitdir?: string | undefined;
remote: string;
}): Promise<void>;
/**
* Delete a local tag ref
*
* @param {Object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} args.ref - The tag to delete
*
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
*
* @example
* await git.deleteTag({ fs, dir: '/tutorial', ref: 'test-tag' })
* console.log('done')
*
*/
export function deleteTag({ fs, dir, gitdir, ref }: {
fs: FsClient;
dir?: string | undefined;
gitdir?: string | undefined;
ref: string;
}): Promise<void>;
/**
* Expand and resolve a short oid into a full oid
*
* @param {Object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} args.oid - The shortened oid prefix to expand (like "0414d2a")
* @param {object} [args.cache] - a [cache](cache.md) object
*
* @returns {Promise<string>} Resolves successfully with the full oid (like "0414d2a286d7bbc7a4a326a61c1f9f888a8ab87f")
*
* @example
* let oid = await git.expandOid({ fs, dir: '/tutorial', oid: '0414d2a'})
* console.log(oid)
*
*/
export function expandOid({ fs, dir, gitdir, oid, cache, }: {
fs: FsClient;
dir?: string | undefined;
gitdir?: string | undefined;
oid: string;
cache?: object;
}): Promise<string>;
/**
* Expand an abbreviated ref to its full name
*
* @param {Object} args
* @param {FsClient} args.fs - a file system implementation
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} args.ref - The ref to expand (like "v1.0.0")
*
* @returns {Promise<string>} Resolves successfully with a full ref name ("refs/tags/v1.0.0")
*
* @example
* let fullRef = await git.expandRef({ fs, dir: '/tutorial', ref: 'main'})
* console.log(fullRef)
*
*/
export function expandRef({ fs, dir, gitdir, ref }: {
fs: FsClient;
dir?: string | undefined;
gitdir?: string | undefined;
ref: string;
}): Promise<string>;
/**
* Like `pull`, but hard-coded with `fastForward: true` so there is no need for an `author` parameter.
*
* @param {object} args
* @param {FsClient} args.fs - a file system client
* @param {HttpClient} args.http - an HTTP client
* @param {ProgressCallback} [args.onProgress] - optional progress event callback
* @param {MessageCallback} [args.onMessage] - optional message event callback
* @param {AuthCallback} [args.onAuth] - optional auth fill callback
* @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
* @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
* @param {string} args.dir] - The [working tree](dir-vs-gitdir.md) directory path
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
* @param {string} [args.ref] - Which branch to merge into. By default this is the currently checked out branch.
* @param {string} [args.url] - (Added in 1.1.0) The URL of the remote repository. The default is the value set in the git config for that remote.
* @param {string} [args.remote] - (Added in 1.1.0) I