Skip to content
API reference

git-commit

Import
import * as api from "@fungi.computer/agar/git-commit";
Kind Export Description
type alias GitCommitStore The binding operations these writes use.
type alias GitFileChange One file to write (content) or delete (content: null), repository-relative.
type alias GitIdentity Name and email recorded as a commit’s author and committer.
type alias CommitFilesRequest A commit of file changes to one branch.
type alias GitWriteOutcome What a compare-and-swap write did.
type alias MergeBranchRequest Merge a branch of source (such as a fork) into a branch of target.
type alias GitMergeOutcome What a merge did. Merges always write a merge commit when there is new work.
type alias MoveRefRequest Point a ref at a commit that is the head of source.
type alias MoveRefsRequest Ordered ref moves to one fetched source commit; each move has its own CAS guard.
type alias GitRefMovesOutcome Earlier moves remain accepted if a later ref is stale; this is not an atomic push.
function commitFiles() Commit files using independently resumable, CAS-guarded Git steps.
function moveRef() Point a ref at the head commit of source, compare-and-swap on the ref.
function moveRefs() Fetch a source once, then move refs in order with separate guarded pushes.
function mergeBranch() Merge branches through the same one-exchange step engine as background owners.

GitCommitStoretype alias

Section titled “GitCommitStore”
Signature
type GitCommitStore = Pick<GitBinding, "exchange">;

The binding operations these writes use.


GitFileChangetype alias

Section titled “GitFileChange”
Signature
type GitFileChange = Readonly<{
path: string;
content: Uint8Array | null;
mode?: "100644" | "100755";
}>;

One file to write (content) or delete (content: null), repository-relative.


GitIdentitytype alias

Section titled “GitIdentity”
Signature
type GitIdentity = Readonly<{
name: string;
email: string;
}>;

Name and email recorded as a commit’s author and committer.


CommitFilesRequesttype alias

Section titled “CommitFilesRequest”
Signature
type CommitFilesRequest = Readonly<{
repository: string;
branch: string;
expectedHead: string | null;
startFrom?: string;
changes: readonly GitFileChange[];
message: string;
author: GitIdentity;
}>;

A commit of file changes to one branch.


GitWriteOutcometype alias

Section titled “GitWriteOutcome”
Signature
type GitWriteOutcome =
| Readonly<{
kind: "committed";
commit: string;
}>
| Readonly<{
kind: "unchanged";
commit: string;
}>
| Readonly<{
kind: "updated";
}>
| Readonly<{
kind: "stale";
head: string | null;
}>;

What a compare-and-swap write did.


MergeBranchRequesttype alias

Section titled “MergeBranchRequest”
Signature
type MergeBranchRequest = Readonly<{
target: string;
source: string;
branch: string;
sourceBranch: string;
expectedSource: string;
expectedTarget?: string;
behind?: number;
message: string;
author: GitIdentity;
}>;

Merge a branch of source (such as a fork) into a branch of target.


GitMergeOutcometype alias

Section titled “GitMergeOutcome”
Signature
type GitMergeOutcome =
| Readonly<{
kind: "merged";
before: string;
after: string;
}>
| Readonly<{
kind: "up-to-date";
head: string;
}>
| Readonly<{
kind: "conflict";
head: string;
paths: readonly string[];
}>
| Readonly<{
kind: "stale";
head: string | null;
}>
| Readonly<{
kind: "source-moved";
head: string;
}>;

What a merge did. Merges always write a merge commit when there is new work.


MoveRefRequesttype alias

Section titled “MoveRefRequest”
Signature
type MoveRefRequest = Readonly<{
repository: string;
ref: string;
expected: string | null;
commit: string;
source: string;
}>;

Point a ref at a commit that is the head of source.


MoveRefsRequesttype alias

Section titled “MoveRefsRequest”
Signature
type MoveRefsRequest = Readonly<{
repository: string;
source: string;
commit: string;
updates: readonly Readonly<{
ref: string;
expected: string | null;
}>[];
}>;

Ordered ref moves to one fetched source commit; each move has its own CAS guard.


GitRefMovesOutcometype alias

Section titled “GitRefMovesOutcome”
Signature
type GitRefMovesOutcome =
| Readonly<{
kind: "updated";
}>
| Readonly<{
kind: "stale";
ref: string;
head: string | null;
}>;

Earlier moves remain accepted if a later ref is stale; this is not an atomic push.

commitFiles()function

Section titled “commitFiles()”
Signature
function commitFiles(store, request, beforeWrite?): Promise<GitWriteOutcome>;

Commit files using independently resumable, CAS-guarded Git steps.

Parameter Type
store GitCommitStore
request CommitFilesRequest
beforeWrite? () => Promise<void>

Promise<GitWriteOutcome>


Signature
function moveRef(store, request): Promise<GitWriteOutcome>;

Point a ref at the head commit of source, compare-and-swap on the ref.

Parameter Type
store GitCommitStore
request MoveRefRequest

Promise<GitWriteOutcome>


Signature
function moveRefs(store, request): Promise<GitRefMovesOutcome>;

Fetch a source once, then move refs in order with separate guarded pushes.

Parameter Type
store GitCommitStore
request MoveRefsRequest

Promise<GitRefMovesOutcome>


mergeBranch()function

Section titled “mergeBranch()”
Signature
function mergeBranch(store, request): Promise<GitMergeOutcome>;

Merge branches through the same one-exchange step engine as background owners.

Parameter Type
store GitCommitStore
request MergeBranchRequest

Promise<GitMergeOutcome>