import { AnnotatedCommit } from "./annotated-commit"; import { Blob } from "./blob"; import { CheckoutOptions } from "./checkout-options"; import { Commit } from "./commit"; import { Config } from "./config"; import { DiffLine } from "./diff-line"; import { Error } from "./error"; import { FetchOptions } from "./fetch-options"; import { Index } from "./index_"; import { Merge } from "./merge"; import { MergeOptions } from "./merge-options"; import { Odb } from "./odb"; import { Oid } from "./oid"; import { Refdb } from "./ref-db"; import { Reference } from "./reference"; import { Remote } from "./remote"; import { Revwalk } from "./rev-walk"; import { Signature } from "./signature"; import { StatusFile } from "./status-file"; import { StatusOptions } from "./status-options"; import { Submodule } from "./submodule"; import { Tag } from "./tag"; import { Tree } from "./tree"; import { Treebuilder } from "./tree-builder"; import { Worktree } from "./worktree"; export interface RepositoryInitOptions { description?: string; flags?: number; initialHead?: string; mode?: number; originUrl?: string; templatePath?: string; version?: number; workdirPath?: string; } export class Repository { /** * Creates a branch with the passed in name pointing to the commit */ static discover(startPath: string, acrossFs: number, ceilingDirs: string): Promise; static init(path: string, isBare: number): Promise; static initExt(repoPath: string, options?: RepositoryInitOptions): Promise; static open(path: string): Promise; static openBare(barePath: string): Promise; static openExt(path: string, flags?: number, ceilingDirs?: string): Promise; static openFromWorktree(wt: Worktree): Promise; static wrapOdb(odb: Odb): Promise; cleanup(): Promise; commondir(): string; config(): Promise; configSnapshot(): Promise; detachHead(): number; fetchheadForeach(callback?: Function): Promise; getNamespace(): string; getSubmodules(): Promise; head(): Promise; headDetached(): number; headUnborn(): number; index(): Promise; isBare(): number; isEmpty(): number; isShallow(): number; itemPath(item: number): Promise; mergeheadForeach(callback?: Function): Promise; messageRemove(): number; odb(): Promise; path(): string; refdb(): Promise; refreshReferences(): Promise; setHead(refname: string): Promise; setHeadDetached(commitish: Oid): number; setHeadDetachedFromAnnotated(commitish: AnnotatedCommit): number; setIdent(name: string, email: string): number; setNamespace(nmspace: string): number; setWorkdir(workdir: string, updateGitLink: number): number; state(): number; stateCleanup(): number; workdir(): string; /** * Creates a branch with the passed in name pointing to the commit */ createBranch(name: string, commit: Commit | string | Oid, force?: boolean): Promise; /** * Look up a refs's commit. */ getReferenceCommit(name: string | Reference): Promise; /** * Look up a branch. Alias for getReference */ getBranch(name: string | Reference): Promise; /** * Look up a branch's most recent commit. Alias to getReferenceCommit */ getBranchCommit(name: string | Reference): Promise; /** * Gets the branch that HEAD currently points to Is an alias to head() */ getCurrentBranch(): Promise; /** * Lookup the reference with the given name. */ getReference(name: string | Reference): Promise; /** * Lookup references for a repository. */ getReferences(): Promise; /** * Lookup reference names for a repository. */ getReferenceNames(type: Reference.TYPE): Promise; getCommit(string: string | Commit | Oid): Promise; /** * Retrieve the blob represented by the oid. */ getBlob(string: string | Oid): Promise; /** * Retrieve the tree represented by the oid. */ getTree(string: string | Oid): Promise; createTag(string: string | Oid, name: string, message: string): Promise; /** * Creates a new lightweight tag */ createLightweightTag(string: string | Oid, name: string): Promise; /** * Retrieve the tag represented by the oid. */ getTag(string: string | Oid): Promise; /** * Retrieve the tag represented by the tag name. */ getTagByName(Short: string): Promise; /** * Deletes a tag from a repository by the tag name. */ deleteTagByName(Short: string): Promise; /** * Instantiate a new revision walker for browsing the Repository"s history. See also Commit.prototype.history() */ createRevWalk(): Revwalk; /** * Retrieve the master branch commit. */ getMasterCommit(): Promise; /** * Retrieve the commit that HEAD is currently pointing to */ getHeadCommit(): Promise; createCommit( updateRef: string, author: Signature, committer: Signature, message: string, Tree: Tree | Oid | string, parents: Array, callback?: Function, ): Promise; createCommitWithSignature( updateRef: string, author: Signature, committer: Signature, message: string, Tree: Tree | Oid | string, parents: Array, onSignature: ( data: string, ) => | Promise<{ code: Error.CODE; field?: string | undefined; signedData: string }> | { code: Error.CODE; field?: string | undefined; signedData: string }, ): Promise; /** * Creates a new commit on HEAD from the list of passed in files */ createCommitOnHead(filesToAdd: string[], author: Signature, committer: Signature, message: string): Promise; /** * Create a blob from a buffer */ createBlobFromBuffer(buffer: Buffer): Promise; treeBuilder(tree: Tree): Promise; /** * Gets the default signature for the default user and now timestamp */ defaultSignature(): Signature; /** * Lists out the names of remotes in the given repository. */ getRemoteNames(): Promise; /** * Lists out the remotes in the given repository. */ getRemotes(callback?: Function): Promise; /** * Gets a remote from the repo */ getRemote(remote: string | Remote, callback?: Function): Promise; /** * Fetches from a remote */ fetch(remote: string | Remote, fetchOptions?: FetchOptions): Promise; /** * Fetches from all remotes. This is done in series due to deadlocking issues with fetching from many remotes that can happen. */ fetchAll(fetchOptions?: FetchOptions, callback?: Function): Promise; mergeBranches( to: string | Reference, from: string | Reference, signature?: Signature, mergePreference?: Merge.PREFERENCE, mergeOptions?: MergeOptions, ): Promise; /** * Rebases a branch onto another branch */ rebaseBranches( branch: string, upstream: string, onto: string, signature: Signature, beforeNextFn: Function, ): Promise; continueRebase(signature: Signature, beforeNextFn: Function): Promise; /** * Get the status of a repo to it's working directory */ getStatus(opts?: StatusOptions): Promise; /** * Get extended statuses of a repo to it's working directory. Status entries have status, headToIndex delta, and indexToWorkdir deltas */ getStatusExt(opts?: StatusOptions): Promise; /** * Get the names of the submodules in the repository. */ getSubmoduleNames(): Promise; /** * This will set the HEAD to point to the reference and then attempt to update the index and working tree to match the content of the latest commit on that reference */ checkoutRef(reference: Reference, opts?: CheckoutOptions): Promise; /** * This will set the HEAD to point to the local branch and then attempt to update the index and working tree to match the content of the latest commit on that branch */ checkoutBranch(branch: string | Reference, opts?: CheckoutOptions): Promise; /** * Stages or unstages line selection of a specified file */ stageFilemode(filePath: string | string[], stageNew: boolean): Promise; /** * Stages or unstages line selection of a specified file */ stageLines(filePath: string, newLines: DiffLine[], isStaged: boolean): Promise; /** * Returns true if the repository is in the default NONE state. */ isDefaultState(): boolean; /** * Returns true if the repository is in the APPLY_MAILBOX or APPLY_MAILBOX_OR_REBASE state. */ isApplyingMailbox(): boolean; /** * Returns true if the repository is in the BISECT state. */ isBisecting(): boolean; /** * Returns true if the repository is in the CHERRYPICK state. */ isCherrypicking(): boolean; /** * Returns true if the repository is in the MERGE state. */ isMerging(): boolean; /** * Returns true if the repository is in the REBASE, REBASE_INTERACTIVE, or REBASE_MERGE state. */ isRebasing(): boolean; /** * Returns true if the repository is in the REVERT state. */ isReverting(): boolean; /** * Discard line selection of a specified file. Assumes selected lines are unstaged. */ discardLines(filePath: string, selectedLines: DiffLine[]): Promise; /** * Grabs a fresh copy of the index from the repository. Invalidates all previously grabbed indexes */ refreshIndex(): Promise; }