Skip to content

steps/git ​

Inspect committed changes and push branches in a Git worktree.

Wrap steps in a factory-owned "use step" file. Never call them directly from a workflow.

Functions ​

branchContains() ​

ts
function branchContains(worktreePath, sha): Promise<boolean>;

Whether sha is the worktree's HEAD or one of its ancestors. A commit the worktree has never fetched is not contained.

Parameters ​

ParameterType
worktreePathstring
shastring

Returns ​

Promise<boolean>


pushApprovedChange() ​

ts
function pushApprovedChange(
   worktreePath, 
   branch, 
   approvedCommit): Promise<{
  headSha: string;
}>;

Push a reviewed commit only while it is still HEAD and the worktree is clean.

Safe to retry after a successful push. Rejects if HEAD moved or any uncommitted change exists.

Parameters ​

ParameterType
worktreePathstring
branchstring
approvedCommitstring

Returns ​

Promise<{ headSha: string; }>


pushBranch() ​

ts
function pushBranch(worktreePath, branch): Promise<{
  headSha: string;
}>;

Push the worktree's current HEAD and register a GitHub branch resource when applicable.

Parameters ​

ParameterType
worktreePathstring
branchstring

Returns ​

Promise<{ headSha: string; }>


readBranchState() ​

ts
function readBranchState(worktreePath, baseSha): Promise<{
  commits: number;
  dirty: boolean;
  headSha: string;
}>;

Inspect the worktree state used to decide whether a branch is ready to push.

Parameters ​

ParameterType
worktreePathstring
baseShastring

Returns ​

Promise<{ commits: number; dirty: boolean; headSha: string; }>


readChange() ​

ts
function readChange(worktreePath, base): Promise<ChangeSummary>;

Describe committed changes between a base ref and the worktree's current HEAD.

Parameters ​

ParameterType
worktreePathstring
basestring

Returns ​

Promise<ChangeSummary>

Remarks ​

Resolves both endpoints once, compares their trees directly and lists commits reachable only from HEAD. Returns at most 1,000 files and 1,000 commits; truncated reports omitted results.


readPatch() ​

ts
function readPatch(
   worktreePath, 
   base, 
   head, 
paths): Promise<ChangePatch>;

Read patches for selected literal paths between two commits.

Parameters ​

ParameterType
worktreePathstring
basestring
headstring
pathsstring[]

Returns ​

Promise<ChangePatch>

Remarks ​

Pass the resolved base and head from readChange to inspect that exact change. Paths are deduplicated, empty paths are rejected and all returned patches share a 200,000-character limit.


readWorktreeDiff() ​

ts
function readWorktreeDiff(worktreePath, baseSha): Promise<string>;

Read a raw patch from the merge base of baseSha and HEAD, truncating after 200,000 characters.

Parameters ​

ParameterType
worktreePathstring
baseShastring

Returns ​

Promise<string>

Released under the MIT License.