@zuke/git
`@zuke/git` — typed `git` task wrappers for Zuke builds.
@zuke/git on JSR ↗ 19 symbols
Symbols
class GitAddSettings extends GitSettings Settings for git add.
| Member | Signature | Doc |
|---|---|---|
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). |
class GitBranchSettings extends GitSettings Settings for git branch.
| Member | Signature | Doc |
|---|---|---|
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). |
class GitCheckoutSettings extends GitSettings Settings for git checkout.
| Member | Signature | Doc |
|---|---|---|
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). |
class GitCloneSettings extends GitSettings Settings for git clone.
| Member | Signature | Doc |
|---|---|---|
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). |
class GitCommitSettings extends GitSettings Settings for git commit.
| Member | Signature | Doc |
|---|---|---|
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). |
class GitFetchSettings extends GitSettings Settings for git fetch.
| Member | Signature | Doc |
|---|---|---|
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). |
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.
interface GitInfo Resolved git repository information.
| Member | Signature | Doc |
|---|---|---|
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. |
interface GitInfoOptions Options for gitInfo.
| Member | Signature | Doc |
|---|---|---|
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. |
class GitInitSettings extends GitSettings Settings for git init.
| Member | Signature | Doc |
|---|---|---|
bare | bare(): this | Create a bare repository (--bare). |
initialBranch | initialBranch(name: string): this | Name the initial branch (-b/--initial-branch). |
class GitPullSettings extends GitSettings Settings for git pull.
| Member | Signature | Doc |
|---|---|---|
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). |
class GitPushSettings extends GitSettings Settings for git push.
| Member | Signature | Doc |
|---|---|---|
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). |
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).
class GitRunSettings extends GitSettings Settings for an arbitrary git command not covered by a typed task.
| Member | Signature | Doc |
|---|---|---|
command | command(...parts: Array<string | number>): this | The subcommand and its arguments, e.g. command("rev-parse", "HEAD"). |
class GitSettings extends ToolSettings Shared base for every git subcommand: the binary and global options.
| Member | Signature | Doc |
|---|---|---|
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. |
class GitStatusSettings extends GitSettings Settings for git status.
| Member | Signature | Doc |
|---|---|---|
short | short(): this | Short-format output (-s/--short). |
porcelain | porcelain(): this | Stable machine-readable output (--porcelain). |
branch | branch(): this | Show branch information (-b/--branch). |
class GitTagSettings extends GitSettings Settings for git tag.
| Member | Signature | Doc |
|---|---|---|
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). |
const GitTasks: GitTasksApi Typed task functions for the common git commands.
interface GitTasksApi The shape of GitTasks.
| Member | Signature | Doc |
|---|---|---|
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(...). |