identity

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package identity resolves raw account identifiers (GitHub usernames, git commit emails, device-scoped local accounts) to a canonical personId, so period reports can aggregate one developer's activity across multiple accounts and machines without conflating people.

GitHub username is never the canonical identity: a developer may have multiple GitHub accounts, several git commit emails, and local OS accounts on more than one machine. Git emails are matched by hash so raw addresses never need to live in a config file.

Index

Constants

View Source
const (
	TypeGitHub       = "github"
	TypeGitEmail     = "git_email"
	TypeLocalAccount = "local_account"
)

Identity types.

Variables

This section is empty.

Functions

func HashEmail

func HashEmail(email string) string

HashEmail returns the canonical hash for a git-email identity: lowercased and trimmed, then SHA-256, formatted as "sha256:<hex>". Callers store this in Identity.ValueHash instead of the raw email, and pass raw addresses to Map.ResolveGitEmail, which hashes them the same way before lookup.

Types

type Identity

type Identity struct {
	Type      string `json:"type"`
	Value     string `json:"value,omitempty"`
	ValueHash string `json:"valueHash,omitempty"`
	DeviceID  string `json:"deviceId,omitempty"`
}

Identity links one account or device-scoped account to a person.

Value holds the identifier for GitHub and local-account identities; git-email identities are stored hashed (ValueHash) so raw emails never need to be committed to a config file. DeviceID scopes local-account identities, since OS usernames collide across machines.

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map resolves identities to person IDs.

func NewMap

func NewMap(people []Person) (*Map, error)

NewMap builds a Map from a set of people. A duplicate identity (the same account claimed by two people) is a configuration error, not a runtime fallback decision, and is rejected.

func (*Map) ResolveGitEmail

func (m *Map) ResolveGitEmail(email string) (string, bool)

ResolveGitEmail returns the personId for a git commit email, if known. The email is hashed before lookup so callers pass raw addresses.

func (*Map) ResolveGitHub

func (m *Map) ResolveGitHub(username string) (string, bool)

ResolveGitHub returns the personId for a GitHub username, if known.

func (*Map) ResolveLocalAccount

func (m *Map) ResolveLocalAccount(deviceID, account string) (string, bool)

ResolveLocalAccount returns the personId for a device-scoped local account, if known.

type Person

type Person struct {
	PersonID   string     `json:"personId"`
	Identities []Identity `json:"identities"`
}

Person links one canonical identity to every account it maps to.

Jump to

Keyboard shortcuts

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