@zuke/git

← API reference

`@zuke/git` — typed `git` task wrappers for Zuke builds.

Symbols

# GitAddSettings class
class GitAddSettings extends GitSettings

Settings for git add.

MemberSignatureDoc
paths paths(...values: PathLike[]): this Paths/pathspecs to stage (positional); repeatable.
all all(): this Stage all changes including new files (-A/--all).
update update(): this Stage modifications and deletions, but not new files (-u/--update).
# GitBranchSettings class
class GitBranchSettings extends GitSettings

Settings for git branch.

MemberSignatureDoc
name name(value: string): this The branch name to create or operate on.
deleteBranch deleteBranch(force?: boolean): this Delete the branch (-d, or -D when forced).
all all(): this List both local and remote-tracking branches (-a/--all).
# GitCheckoutSettings class
class GitCheckoutSettings extends GitSettings

Settings for git checkout.

MemberSignatureDoc
ref ref(target: string): this The branch or commit to check out — or, with paths, the source to restore those paths from. Required unless paths is given.
paths paths(...paths: string[]): this Restore one or more paths (git checkout [<ref>] -- <paths>). The -- separates paths from any ref so a path is never misread as a branch name; repeatable. With no ref, restores the paths from the index (discarding working-tree changes).
create create(): this Create a new branch (-b).
force force(): this Force checkout, discarding local changes (-f/--force).
# GitCloneSettings class
class GitCloneSettings extends GitSettings

Settings for git clone.

MemberSignatureDoc
repository repository(url: string): this The repository URL to clone (required).
directory directory(path: PathLike): this Target directory for the clone.
branch branch(name: string): this Check out a specific branch (-b/--branch).
depth depth(commits: number): this Create a shallow clone of the given depth (--depth).
bare bare(): this Clone a bare repository (--bare).
# GitCommitSettings class
class GitCommitSettings extends GitSettings

Settings for git commit.

MemberSignatureDoc
message message(text: string): this The commit message (-m).
all all(): this Stage modified/deleted files before committing (-a/--all).
amend amend(): this Amend the previous commit (--amend).
noEdit noEdit(): this Keep the existing message when amending (--no-edit).
allowEmpty allowEmpty(): this Allow a commit with no changes (--allow-empty).
# GitFetchSettings class
class GitFetchSettings extends GitSettings

Settings for git fetch.

MemberSignatureDoc
remote remote(name: string): this The remote to fetch from.
all all(): this Fetch from all remotes (--all).
tags tags(): this Also fetch tags (--tags).
prune prune(): this Prune deleted remote refs (--prune).
# gitInfo function
async function gitInfo(options?: GitInfoOptions): Promise<GitInfo>

Resolve GitInfo for the repository at cwd. Throws if cwd is not a git repository (or git is unavailable). Optional fields (tag, remoteUrl) are undefined when absent.

# GitInfo interface
interface GitInfo

Resolved git repository information.

MemberSignatureDoc
branch branch: string Current branch, or "HEAD" when detached.
commit commit: string Full commit SHA of HEAD.
shortCommit shortCommit: string Abbreviated commit SHA.
tag? tag?: string The nearest tag (git describe --tags --abbrev=0), if any.
dirty dirty: boolean Whether the working tree has uncommitted changes.
remoteUrl? remoteUrl?: string The origin remote URL, if configured.
# GitInfoOptions interface
interface GitInfoOptions

Options for gitInfo.

MemberSignatureDoc
cwd? cwd?: string Directory to inspect (defaults to the current directory).
run? run?: GitRunner Override how git is invoked (defaults to spawning git); for testing.
# GitInitSettings class
class GitInitSettings extends GitSettings

Settings for git init.

MemberSignatureDoc
bare bare(): this Create a bare repository (--bare).
initialBranch initialBranch(name: string): this Name the initial branch (-b/--initial-branch).
# GitPullSettings class
class GitPullSettings extends GitSettings

Settings for git pull.

MemberSignatureDoc
remote remote(name: string): this The remote to pull from.
ref ref(value: string): this The refspec/branch to pull.
rebase rebase(): this Rebase instead of merge (--rebase).
ffOnly ffOnly(): this Only fast-forward (--ff-only).
# GitPushSettings class
class GitPushSettings extends GitSettings

Settings for git push.

MemberSignatureDoc
remote remote(name: string): this The remote to push to (e.g. origin).
ref ref(value: string): this The refspec/branch to push.
setUpstream setUpstream(): this Set the upstream tracking ref (-u/--set-upstream).
tags tags(): this Also push tags (--tags).
forceWithLease forceWithLease(): this Force push, but only if the remote ref is unchanged (--force-with-lease).
deleteRef deleteRef(): this Delete the remote ref (--delete).
# GitRunner type
type GitRunner = unknown

Runs a git subcommand and resolves to its trimmed stdout, or null when the command fails (non-zero exit, or git unavailable).

# GitRunSettings class
class GitRunSettings extends GitSettings

Settings for an arbitrary git command not covered by a typed task.

MemberSignatureDoc
command command(...parts: Array<string | number>): this The subcommand and its arguments, e.g. command("rev-parse", "HEAD").
# GitSettings class
class GitSettings extends ToolSettings

Shared base for every git subcommand: the binary and global options.

MemberSignatureDoc
dir dir(path: PathLike): this Run git as if started in path (-C <path>).
config config(key: string, value: string): this Set a one-off config value (-c key=value); repeatable.
# GitStatusSettings class
class GitStatusSettings extends GitSettings

Settings for git status.

MemberSignatureDoc
short short(): this Short-format output (-s/--short).
porcelain porcelain(): this Stable machine-readable output (--porcelain).
branch branch(): this Show branch information (-b/--branch).
# GitTagSettings class
class GitTagSettings extends GitSettings

Settings for git tag.

MemberSignatureDoc
name name(value: string): this The tag name.
message message(text: string): this Create an annotated tag with this message (-a -m).
force force(): this Replace an existing tag (-f/--force).
deleteTag deleteTag(): this Delete the tag (-d/--delete).
# GitTasks const
const GitTasks: GitTasksApi

Typed task functions for the common git commands.

# GitTasksApi interface
interface GitTasksApi

The shape of GitTasks.

MemberSignatureDoc
init init(configure?: Configure<GitInitSettings>): Promise<CommandOutput> Create a repository: git init.
clone clone(configure?: Configure<GitCloneSettings>): Promise<CommandOutput> Clone a repository: git clone.
add add(configure?: Configure<GitAddSettings>): Promise<CommandOutput> Stage changes: git add.
commit commit(configure?: Configure<GitCommitSettings>): Promise<CommandOutput> Record changes: git commit.
status status(configure?: Configure<GitStatusSettings>): Promise<CommandOutput> Show working-tree status: git status.
checkout checkout(configure?: Configure<GitCheckoutSettings>): Promise<CommandOutput> Switch branches or restore files: git checkout.
branch branch(configure?: Configure<GitBranchSettings>): Promise<CommandOutput> Manage branches: git branch.
tag tag(configure?: Configure<GitTagSettings>): Promise<CommandOutput> Manage tags: git tag.
push push(configure?: Configure<GitPushSettings>): Promise<CommandOutput> Update remote refs: git push.
pull pull(configure?: Configure<GitPullSettings>): Promise<CommandOutput> Fetch and integrate: git pull.
fetch fetch(configure?: Configure<GitFetchSettings>): Promise<CommandOutput> Download objects and refs: git fetch.
run run(configure?: Configure<GitRunSettings>): Promise<CommandOutput> Run any other git command via .command(...).