control

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: 0BSD Imports: 32 Imported by: 0

Documentation

Overview

Package control implements the forge control commands executed over SSH. Every command here is reachable from bare OpenSSH: argv in, JSON or plain text on stdout, diagnostics on stderr, exit code out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(c *Ctx, argv []string) int

Dispatch runs argv for an authenticated session. The dispatcher — not the handlers — enforces key scope: control commands require a full-scope key.

func HooksDir

func HooksDir(root string) string

HooksDir is the shared core.hooksPath directory.

func ProcessCommitMessages added in v0.2.0

func ProcessCommitMessages(st *store.Store, dir string, repo store.Repo, actorID int64, old, new string)

ProcessCommitMessages acts on issue references in commits that just landed on the default branch (old..new): closing keywords close the issue, bare #N leaves a reference comment. Each (issue, sha) pair acts at most once, ever. actorID — the pusher or merger — authorizes and signs the resulting comments; failures are logged, never fatal, because this runs after the push or merge already succeeded.

func RecordLandedCommits added in v0.3.0

func RecordLandedCommits(st *store.Store, dir string, repo store.Repo, old, new string)

RecordLandedCommits attributes commits that just landed on the default branch to accounts by verified author email, for the activity graph. Dedup by (repo, sha) makes rebases and re-runs harmless; unresolvable authors are simply not activity.

func RegisterAccount added in v0.2.0

func RegisterAccount(cfg config.Config, st *store.Store, pub ssh.PublicKey, username, email, invite string) (string, string, int)

RegisterAccount creates an account for pub under the instance's registration mode. On success it returns the human message and ExitOK; otherwise an error message and the classifying exit code. Shared by the SSH register command and the web signup form.

func RepoDir

func RepoDir(root, owner, name string) string

RepoDir returns the on-disk path for a repository.

func RunRegister

func RunRegister(cfg config.Config, st *store.Store, pub ssh.PublicKey, argv []string,
	stdout, stderr io.Writer) int

RunRegister handles the one command an UNAUTHENTICATED key may run. It is dispatched outside the normal registry: the caller has already checked that registration is enabled and that argv[0] == "register".

func VerifyCommitCached

func VerifyCommitCached(st *store.Store, repo store.Repo, parsed *sig.Commit, sha string) (sig.Result, error)

VerifyCommitCached verifies one commit with the epoch cache. Shared with the web UI.

Types

type Command

type Command struct {
	Path       []string // e.g. ["keys", "add"]
	Summary    string
	ReadsStdin bool
	ReadOnly   bool // safe for read-scoped API tokens
	SSHOnly    bool // refused over the HTTP API (credential minting)
	Run        func(c *Ctx, args []string) int
}

func Commands

func Commands() []Command

Commands returns the registry, for the bare-ssh reachability test.

func Lookup

func Lookup(argv []string) (Command, []string, bool)

Lookup resolves argv to a command by longest path match, returning the command and the remaining arguments.

type Ctx

type Ctx struct {
	User   store.User
	Scope  string // scope of the key that authenticated this session
	Store  *store.Store
	Cfg    config.Config
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	JSON   bool
	// ViaAPI marks requests arriving over the HTTP token API. Some
	// commands (token management) are SSH-only: an API token must never
	// mint further credentials.
	ViaAPI bool
	// ReadOnly is set for read-scoped API tokens.
	ReadOnly bool
	// Source identifies the credential behind this session for the audit
	// log: an SSH key fingerprint, or "api" for token requests.
	Source string
}

type IssueTemplate added in v0.2.0

type IssueTemplate struct {
	Name string `json:"name"`
	Body string `json:"body"`
}

func IssueTemplates added in v0.2.0

func IssueTemplates(dir, ref string) []IssueTemplate

IssueTemplates reads .gitbay/issue-template*.md from ref. Missing directory or unreadable files yield an empty list, never an error.

Source Files

  • audit.go
  • build.go
  • commitrefs.go
  • control.go
  • deploykey.go
  • diffcomment.go
  • ghimport.go
  • identity.go
  • import.go
  • issue.go
  • migrate.go
  • milestone.go
  • mirrorcmd.go
  • mr.go
  • notifications.go
  • org.go
  • pagescmd.go
  • profile.go
  • register.go
  • release.go
  • repo.go
  • sig.go
  • status.go
  • teams.go
  • token.go
  • web.go
  • webhook.go

Jump to

Keyboard shortcuts

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