gate

package
v1.55.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RemoteName       = "no-slop"
	LegacyRemoteName = "no-mistakes"
)

RemoteName is the canonical Git remote that points to the local gate. LegacyRemoteName remains wired to the exact same bare repository.

Variables

This section is empty.

Functions

func Eject

func Eject(ctx context.Context, d *db.DB, p *paths.Paths, workDir string) (*db.Repo, error)

Eject removes the no-slop gate from the repo at workDir. It removes both working-tree remotes, deletes the bare repo and worktrees, and deletes the repo record from the database.

func Init

func Init(ctx context.Context, d *db.DB, p *paths.Paths, workDir string) (*db.Repo, bool, error)

Init sets up a no-slop gate for the git repo at workDir. It creates a bare repo, installs the post-receive hook, best-effort isolates the bare repo's hooks path from shared local config writes when Git supports config --worktree, adds the canonical no-slop remote and the no-mistakes compatibility remote, and records the repo in the database.

Init is idempotent: re-running it on an already-initialized repo repairs and refreshes the gate (for example installing a newer hook, picking up hook-path isolation, or restoring a missing remote) instead of failing. This includes a working directory that was renamed or moved since the gate was created: the gate identified by a leftover no-slop or no-mistakes remote is reattached at the new path, preserving its run history. The returned bool reports whether a new gate was created (true) or an existing one was refreshed (false).

func InitWithFork

func InitWithFork(ctx context.Context, d *db.DB, p *paths.Paths, workDir, forkURL string) (*db.Repo, bool, error)

InitWithFork is Init plus an optional GitHub fork push URL. The origin remote remains the parent repository used for PRs. When forkURL is empty, an existing fork setting is preserved across idempotent refreshes.

func RefreshRepoURLs

func RefreshRepoURLs(ctx context.Context, database *db.DB, repo *db.Repo) (*db.Repo, bool, error)

RefreshRepoURLs best-effort discovers the current registered targets from the working clone and atomically replaces both URL fields. Origin remains the authoritative upstream source. An existing fork is refreshed only when one unique clone remote still identifies that same fork repository.

It never mutates Git configuration. Every failure is deliberately URL-free so callers can safely log only ReasonForRefreshFailure and continue with the exact repo value they already hold.

Types

type RefreshFailureReason

type RefreshFailureReason string

RefreshFailureReason is a bounded, URL-free reason safe to emit in logs.

const (
	RefreshRemoteUnreadable RefreshFailureReason = "remote_unreadable"
	RefreshAmbiguousRemote  RefreshFailureReason = "ambiguous_remote"
	RefreshInvalidRemote    RefreshFailureReason = "invalid_remote"
	RefreshDatabaseWrite    RefreshFailureReason = "database_write"
)

func ReasonForRefreshFailure

func ReasonForRefreshFailure(err error) RefreshFailureReason

ReasonForRefreshFailure returns a bounded reason that contains no remote URL or wrapped dependency output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL