git.ts

Declarations
#

25 declarations

view source

git_check_clean_workspace
#

git.ts view source

(options?: SpawnOptions | undefined): Promise<string | null>

options?

type SpawnOptions | undefined
optional

returns

Promise<string | null>

an error message if the git workspace has any unstaged or uncommitted changes, or null if it's clean

git_check_fully_staged_workspace
#

git.ts view source

(options?: SpawnOptions | undefined): Promise<string | null>

options?

type SpawnOptions | undefined
optional

returns

Promise<string | null>

an error message if the git workspace has any unstaged changes or untracked files, or null if fully staged

git_check_setting_pull_rebase
#

git.ts view source

(options?: SpawnOptions | undefined): Promise<boolean>

Returns the global git config setting for pull.rebase.

options?

type SpawnOptions | undefined
optional

returns

Promise<boolean>

git_check_workspace
#

git.ts view source

(options?: SpawnOptions | undefined): Promise<GitWorkspaceStatus>

Checks the git workspace status using a single git status --porcelain -z call. The -z format provides more reliable parsing by using NUL separators and avoiding escaping.

options?

type SpawnOptions | undefined
optional

returns

Promise<GitWorkspaceStatus>

status object with flags for unstaged changes, staged changes, and untracked files

git_checkout
#

git.ts view source

(branch: GitBranch, options?: SpawnOptions | undefined): Promise<GitBranch | null>

Calls git checkout and throws if anything goes wrong.

branch

options?

type SpawnOptions | undefined
optional

returns

Promise<GitBranch | null>

the previous branch name, if it changed

git_clone_locally
#

git.ts view source

(origin: GitOrigin, branch: GitBranch, source_dir: string, target_dir: string, options?: SpawnOptions | undefined): Promise<void>

Clones a branch locally to another directory and updates the origin to match the source.

origin

branch

source_dir

type string

target_dir

type string

options?

type SpawnOptions | undefined
optional

returns

Promise<void>

git_current_branch_first_commit_hash
#

git.ts view source

(options?: SpawnOptions | undefined): Promise<string>

Returns the hash of the current branch's first commit or throws if something goes wrong.

options?

type SpawnOptions | undefined
optional

returns

Promise<string>

git_current_branch_name
#

git.ts view source

(options?: SpawnOptions | undefined): Promise<GitBranch>

Returns the current git branch name or throws if something goes wrong.

options?

type SpawnOptions | undefined
optional

returns

Promise<GitBranch>

git_current_commit_hash
#

git.ts view source

(branch?: string | undefined, options?: SpawnOptions | undefined): Promise<string | null>

Returns the branch's latest commit hash or throws if something goes wrong.

branch?

type string | undefined
optional

options?

type SpawnOptions | undefined
optional

returns

Promise<string | null>

git_delete_local_branch
#

git.ts view source

(branch: GitBranch, options?: SpawnOptions | undefined): Promise<void>

Deletes a branch locally and throws if anything goes wrong.

branch

options?

type SpawnOptions | undefined
optional

returns

Promise<void>

git_delete_remote_branch
#

git.ts view source

(origin: GitOrigin, branch: GitBranch, options?: SpawnOptions | undefined): Promise<void>

Deletes a branch remotely and throws if anything goes wrong.

origin

branch

options?

type SpawnOptions | undefined
optional

returns

Promise<void>

git_fetch
#

git.ts view source

(origin?: GitOrigin, branch?: GitBranch | undefined, options?: SpawnOptions | undefined): Promise<void>

Calls git fetch and throws if anything goes wrong.

origin

default 'origin' as GitOrigin

branch?

type GitBranch | undefined
optional

options?

type SpawnOptions | undefined
optional

returns

Promise<void>

git_local_branch_exists
#

git.ts view source

(branch: GitBranch, options?: SpawnOptions | undefined): Promise<boolean>

branch

options?

type SpawnOptions | undefined
optional

returns

Promise<boolean>

a boolean indicating if the local git branch exists

git_parse_workspace_status
#

git.ts view source

(stdout: string | null): GitWorkspaceStatus

Parses the output of git status --porcelain -z (v1 format) into a status object. This is a pure function that can be tested independently.

Format: XY path\0 where: - X = staged status (index) - Y = unstaged status (work tree) - path = file path (unescaped with -z)

Supported status codes: - M = modified - A = added - D = deleted - R = renamed - C = copied - T = type changed (regular file, symbolic link or submodule) - U = unmerged - ? = untracked - ! = ignored

For renames/copies: XY new\0old\0 (two NUL-separated paths)

Note: This implementation treats submodules the same as regular files. Submodule-specific status codes (lowercase m, ?) are interpreted as changes.

stdout

- The raw output from git status --porcelain -z

type string | null

returns

GitWorkspaceStatus

status object with flags for unstaged changes, staged changes, and untracked files

git_pull
#

git.ts view source

(origin?: GitOrigin, branch?: GitBranch | undefined, options?: SpawnOptions | undefined): Promise<void>

Calls git pull and throws if anything goes wrong.

origin

default 'origin' as GitOrigin

branch?

type GitBranch | undefined
optional

options?

type SpawnOptions | undefined
optional

returns

Promise<void>

git_push
#

git.ts view source

(origin: GitOrigin, branch?: GitBranch | undefined, options?: SpawnOptions | undefined, set_upstream?: boolean): Promise<void>

Calls git push and throws if anything goes wrong.

origin

branch?

type GitBranch | undefined
optional

options?

type SpawnOptions | undefined
optional

set_upstream

type boolean
default false

returns

Promise<void>

git_push_to_create
#

git.ts view source

(origin?: GitOrigin, branch?: GitBranch | undefined, options?: SpawnOptions | undefined): Promise<void>

Calls git push and throws if anything goes wrong.

origin

default 'origin' as GitOrigin

branch?

type GitBranch | undefined
optional

options?

type SpawnOptions | undefined
optional

returns

Promise<void>

git_remote_branch_exists
#

git.ts view source

(origin?: GitOrigin, branch?: GitBranch | undefined, options?: SpawnOptions | undefined): Promise<boolean>

origin

default 'origin' as GitOrigin

branch?

type GitBranch | undefined
optional

options?

type SpawnOptions | undefined
optional

returns

Promise<boolean>

a boolean indicating if the remote git branch exists

git_reset_branch_to_first_commit
#

git.ts view source

(origin: GitOrigin, branch: GitBranch, options?: SpawnOptions | undefined): Promise<void>

Resets the target branch back to its first commit both locally and remotely.

origin

branch

options?

type SpawnOptions | undefined
optional

returns

Promise<void>

git_workspace_is_clean
#

git_workspace_is_fully_staged
#

git.ts view source

(status: GitWorkspaceStatus): boolean

status

returns

boolean

true if the workspace has no unstaged changes and no untracked files (staged changes are OK)

git_workspace_status_message
#

GitBranch
#

GitOrigin
#

GitWorkspaceStatus
#

git.ts view source

GitWorkspaceStatus

Git workspace status flags indicating which types of changes are present.

unstaged_changes

type boolean

staged_changes

type boolean

untracked_files

type boolean

Depends on
#