Documentation
¶
Overview ¶
Package identity names the machine and the agent behind an automated commit.
A checkpoint commit made by [gz-git handoff end] is written without anyone watching, so the commit itself has to say where it came from. Reading a work branch later, "which machine left this half-finished" is the question that decides whether it is safe to rebase, and git records only the author — which is the same person on every machine they own.
Index ¶
Constants ¶
const ( EnvDevice = "GZ_GIT_DEVICE" EnvAgent = "GZ_GIT_AGENT" )
Environment variables that name the current machine and agent. They win over configuration because an agent process knows its own name at launch, while a config file is written once and shared by every run on the machine.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Identity ¶
type Identity struct {
// Device names the machine. Defaults to the hostname.
Device string `yaml:"device,omitempty" json:"device,omitempty"`
// Agent names the automation acting on this machine. Empty means a person
// is driving, so there is nothing to record.
Agent string `yaml:"agent,omitempty" json:"agent,omitempty"`
}
Identity is who made a commit, beyond the git author.
It belongs in machine-local configuration — the global config file or a profile — and not in a project's .gz-git.yaml, which is committed and would then give every machine that clones it the same device name.
func FromMessage ¶
FromMessage reads back the identity a commit message was signed with.
A message with no trailers yields a zero Identity, which is not the same as "made by nobody": most commits are written by hand and carry no trailer at all, so an empty result means unknown rather than absent.
func Resolve ¶
Resolve fills in an identity from the environment and the hostname.
A nil or partial configured identity is normal: most machines set nothing and still get a usable device name.
func (Identity) AppendTrailers ¶
AppendTrailers returns message with the identity's trailers added, skipping any the message already carries so the result is stable under a rerun.
func (Identity) DiffersFrom ¶
DiffersFrom reports whether other is positive evidence of a different writer.
It compares only the fields both sides name. An unsigned commit differs from nothing: it is unattributed, not attributed elsewhere, and treating the absence of a trailer as a foreign writer would fire on every commit made by hand.