Documentation
¶
Overview ¶
Package workspace is ynf's git: a mirror per repository, a checkout per step, and the commit and push that only ynf (never the agent) performs (ADR-007). The token reaches git through environment configuration, so it never appears in a process listing.
Index ¶
- type Author
- type Workspace
- func (w Workspace) Changed(ctx context.Context, wt string) ([]string, error)
- func (w Workspace) Checkout(ctx context.Context, mirror, ref, dir string) (string, error)
- func (w Workspace) Commit(ctx context.Context, wt, message string) (string, error)
- func (w Workspace) Diff(ctx context.Context, wt, base string) (string, error)
- func (w Workspace) FirstParent(ctx context.Context, mirror, sha string) (string, error)
- func (w Workspace) Head(ctx context.Context, wt string) (string, error)
- func (w Workspace) Mirror(ctx context.Context, repo string) (string, error)
- func (w Workspace) Push(ctx context.Context, wt, repo, branch string) error
- func (w Workspace) PushFastForward(ctx context.Context, wt, repo, branch string) error
- func (w Workspace) RangeDiff(ctx context.Context, mirror, from, to string) (string, error)
- func (w Workspace) RemoteHas(ctx context.Context, mirror, branch string) bool
- func (w Workspace) RemoteSHA(ctx context.Context, mirror, branch string) (string, error)
- func (w Workspace) RemoveCheckout(dir string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Workspace ¶
type Workspace struct {
Root string
Token string
Author Author
// RemoteURL maps owner/name to a clone URL. Default https://github.com/<repo>.git.
RemoteURL func(repo string) string
}
Workspace manages mirrors and checkouts under Root.
func (Workspace) Checkout ¶
Checkout makes a self-contained clone of the mirror at origin/<ref>, detached, and returns its real path. Real, because a symlinked path makes git and linters disagree about which files changed (ADR-007).
A clone rather than a git worktree: a worktree's .git is a file pointing into the mirror by absolute host path, so a container that mounts only the checkout has no repository. Here .git is a real folder inside dir, and the one mount is enough. --local hardlinks the mirror's objects (no copy on the same filesystem); --shared would not do, as its alternates file points back into the mirror. The clone keeps the mirror's remote-tracking branch as origin/<ref>, so `--new-from-merge-base=origin/main` works in the run.
func (Workspace) Diff ¶
Diff is everything the checkout differs from base by, new files included: the agent's patch. It stages the change, as Changed does.
func (Workspace) FirstParent ¶
FirstParent is the commit before a merge: the first parent of sha in the mirror. For a squash merge it is the base branch as it was; for a merge commit, the same, with the branch merged in.
func (Workspace) Mirror ¶
Mirror clones the repository, or fetches it if already cloned, and returns its real path.
func (Workspace) Push ¶
Push force-pushes HEAD to branch. ynf only force-pushes branches it originated; adopted branches are never force-pushed (ADR-007).
func (Workspace) PushFastForward ¶
PushFastForward pushes HEAD to branch only if that is a fast-forward: the push to someone else's branch, which must never overwrite their work (ADR-007).
func (Workspace) RangeDiff ¶
RangeDiff is the change from one commit to another in the mirror: the human patch.
func (Workspace) RemoteHas ¶
RemoteHas reports whether origin has the branch (after the last fetch).
func (Workspace) RemoveCheckout ¶
RemoveCheckout deletes a checkout. It is a whole repository, so there is no registration to undo.