identity

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 3 Imported by: 0

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

View Source
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

func FromMessage(message string) Identity

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

func Resolve(configured *Identity) Identity

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

func (i Identity) AppendTrailers(message string) string

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

func (i Identity) DiffersFrom(other Identity) bool

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.

func (Identity) Known

func (i Identity) Known() bool

Known reports whether the identity names anything at all.

func (Identity) Name

func (i Identity) Name() string

Name renders the identity for a person to read: "device/agent" when both are named, otherwise whichever one is. An unknown identity renders as "unknown" rather than as an empty string, so it cannot be mistaken for a missing field.

func (Identity) Trailers

func (i Identity) Trailers() []string

Trailers renders the identity as git trailer lines, in the order they should appear. An unnamed field contributes nothing.

Jump to

Keyboard shortcuts

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