commits

package
v0.0.0-...-6f1d02b Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package commits keeps the latest default-branch commits of every catalogued repository and serves the merged commit feeds.

Index

Constants

View Source
const Kind = "commits"

Kind is the job kind of the per-repository refresh.

Variables

This section is empty.

Functions

func ArchiveEntry

func ArchiveEntry(s *snapshot.Snapshot, e *snapshot.RepoEntry, a *oapi.ArchiveEntry)

ArchiveEntry completes a retired repository's row: when it was last active (its newest commit, when one is held) and how many authors its newest commits have, people's work only, counted and never named (design/archive.md).

func Assistant

func Assistant(name string) string

Assistant is the family of an assistant's name, its first word: "Claude Opus 5" is "Claude".

func Authorship

func Authorship(s *snapshot.Snapshot, e *snapshot.RepoEntry) (people, top int)

Authorship is how the people's recent work on a repository is shared (design/insights.md): how many of its newest default-branch commits are people's (automation and sweeps left out) and how many the busiest author wrote. Authors are counted, never returned.

func Dashboard

func Dashboard(s *snapshot.Snapshot, d *oapi.Dashboard)

Dashboard adds the commits to the dashboard through its lens (d.Work): the latest commits of the work that counts, the activity of the fleet and of each group (with its members' last change of that work), each group's last activity and the commits' freshness counts.

func Detail

Detail adds the newest commits and their freshness to a repository's detail.

func Feeds

func Feeds(r *Rules) snapshot.Indexer

Feeds is the indexer of the merged commit feeds, for snapshot.NewPublisher, classifying with r (nil: the built-in rules).

func LastAuthored

func LastAuthored(s *snapshot.Snapshot, k snapshot.RepoKey, w Work) (at time.Time, before bool)

LastAuthored returns the time of the newest commit of the repository k in the view s that is work of the lens w (Counts). When no read commit is, it returns the oldest read commit's time with before set: the last such commit is older. Zero when there are no commits.

func LastCommit

func LastCommit(e *snapshot.RepoEntry) (time.Time, snapshot.Freshness)

LastCommit returns the time of the newest commit of e (zero when there is none) and the commits' freshness.

func Repo

func Repo(s *snapshot.Snapshot, e *snapshot.RepoEntry, r *oapi.Repo)

Repo adds the time of the last commit to a repository summary.

func RepoActivity

func RepoActivity(s *snapshot.Snapshot, k snapshot.RepoKey, w Work) oapi.Activity

RepoActivity is the activity of the repository k in the view s through the lens w, as a group's is summed.

func Sweep

func Sweep(s *snapshot.Snapshot, c *Commit) bool

Sweep reports whether c is part of a sweep in the view s: its subject landed in more than 10 repositories on its day.

Types

type API

type API struct {
	Current func(context.Context) *snapshot.Snapshot // the viewer's view
}

API serves the merged commit feeds from the current snapshot. It implements the commits methods of the strict server.

func (API) GetHistory

GetHistory serves a page of a repository's history in graph order.

type AssistantRule

type AssistantRule struct {
	Name      string
	Authors   []string // an author's login or name
	CoAuthors []string // a Co-authored-by trailer's name, address or local part
}

AssistantRule is an assistant a deployment names (commits.assistants, design/layout.md, P-127): the authors that are it as a coding agent, and the co-authors that mark a person's commit as made with it. Every entry is matched case-insensitively; a co-author entry matches a trailer's name, its address, or its address's local part (after a noreply address's "<id>+", on any host).

type Commit

type Commit struct {
	SHA           string    `json:"sha"`
	Subject       string    `json:"subject"`        // first line of the message
	Body          string    `json:"body,omitempty"` // the rest of the message
	AuthorName    string    `json:"authorName"`
	AuthorLogin   string    `json:"authorLogin,omitempty"`
	CommitterName string    `json:"committerName,omitempty"`
	URL           string    `json:"url"`
	CommittedAt   time.Time `json:"committedAt"`
	Parents       []string  `json:"parents"`           // first parent first
	Stats         *Stats    `json:"stats,omitempty"`   // nil until asked (design/diffstat.md)
	NoStats       bool      `json:"noStats,omitempty"` // asked, and GitHub had none: never asked again
}

Commit is one commit of a repository's history.

func Of

Of returns the default-branch commits of e, newest first, with their freshness.

type CommitInfo

type CommitInfo struct {
	SHA, Message, AuthorName, AuthorLogin, CommitterName, HTMLURL string
	Date                                                          time.Time // committer date
	Parents                                                       []string  // first parent first
}

CommitInfo is a commit as GitHub lists it; normalise cleans the fields.

type Commits

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

Commits is the commits feature.

func New

func New(sources map[string]Fetcher) *Commits

New returns the feature for one Fetcher per source id.

func (*Commits) Spec

func (c *Commits) Spec() sync.Spec

Spec is the per-repository refresh job. A tag pushed or deleted refreshes it too: the history carries the tags as labels.

type Edge

type Edge struct {
	From, To int
	Color    int  // the lane's colour, 0..5
	Open     bool // the line leads to a parent older than the stored history
}

Edge is a line through a row of the git graph, from a lane at its top (or its node) to a lane at its bottom (or its node).

type Fetcher

type Fetcher interface {
	// Commits lists page (from 1) of the commits reachable from ref ("" for the default branch), 100 per page, newest first; more
	// tells whether another page follows.
	Commits(ctx context.Context, owner, name, ref string, page int) (cs []CommitInfo, more bool, err error)
	// Branches and Tags list the first 100 branches and tags.
	Branches(ctx context.Context, owner, name string) ([]RefInfo, error)
	Tags(ctx context.Context, owner, name string) ([]RefInfo, error)
	// Stats asks the diff stats of at most statsBatch commits by SHA; a commit GitHub does not answer is left out.
	Stats(ctx context.Context, owner, name string, shas []string) (map[string]Stats, error)
}

Fetcher reads a repository's history.

func FromGitHub

func FromGitHub(src REST) Fetcher

FromGitHub lists commits through src.

type History

type History struct {
	Main   []Commit
	Side   []Commit
	Labels []Label // the default branch first, then branches, then tags
	Order  []*Commit
	Rows   []Row // the git graph of Order
	// contains filtered or unexported fields
}

History is a repository's stored history: the default branch, the commits only on other branches, their labels, and the graph order the navigator pages through (newest first by commit time, a parent never before its child).

func HistoryOf

func HistoryOf(e *snapshot.RepoEntry) (*History, snapshot.Freshness)

HistoryOf returns the history of e (nil when there is none) with its freshness.

func (*History) LabelsAt

func (h *History) LabelsAt(sha string) []Label

LabelsAt returns the labels of the commit sha.

func (*History) Position

func (h *History) Position(sha string) (int, bool)

Position returns the index of sha in the graph order.

type Label

type Label struct {
	Name    string `json:"name"`
	Kind    string `json:"kind"` // branch | tag
	SHA     string `json:"sha"`
	Default bool   `json:"-"` // the default branch; set at publish
}

Label is a branch or a tag at a commit of the history.

type Origin

type Origin uint8

Origin is who made a commit (design/layout.md, P-40): a person, a person with an AI, a coding agent, or automation.

const (
	OriginPerson     Origin = iota // a person, no trace of an AI
	OriginAssisted                 // a person with an AI co-author (trailer) or an AI tool's footer
	OriginAgent                    // a coding agent as the author
	OriginAutomation               // CI, dependency and release bots
)

func Classify

func Classify(s *snapshot.Snapshot, c *Commit) (Origin, string)

Classify is the origin of c and the assistant it names in the view s, by the rules its feeds were built with.

func (Origin) AI

func (k Origin) AI() bool

AI reports whether the commit carries an AI's work: assisted or by an agent.

func (Origin) String

func (k Origin) String() string

type REST

type REST interface {
	REST(ctx context.Context, owner, name string) (*gh.Client, error)
	GraphQLURL() string
}

REST is a source's GitHub API client per owner and its GraphQL endpoint; *github.Source implements it.

type Ref

type Ref struct {
	Repo   snapshot.RepoKey
	Commit *Commit // points into the repository's facet
	Person bool    // a person's work in the view (not automation, not a sweep), an agent's included; set in the feeds index only
	Origin Origin  // set in the feeds index only
	AI     string  // the assistant's family (Assistant) when Origin.AI
	Named  string  // the assistant's full name when Origin.AI
}

Ref is a commit in a merged feed.

type RefInfo

type RefInfo struct{ Name, SHA string }

RefInfo is a branch or a tag and the commit it points at.

type Row

type Row struct {
	Lane, Color  int
	Merge        bool
	Above, Below []Edge
}

Row is how one commit's row of the git graph draws: its node, the lines in from above and the lines out below.

type Rules

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

Rules classify commits: the built-in tables and the assistants a deployment adds. The nil Rules are the built-in ones.

func NewRules

func NewRules(added []AssistantRule) *Rules

NewRules returns the built-in rules with the assistants added; an added entry wins over the built-in reading of the same author or co-author (a configured "[bot]" co-author is an AI, not automation).

func (*Rules) Automated

func (r *Rules) Automated(c *Commit) bool

Automated reports whether a commit was made by automation (Classify): CI, dependency and release bots, not coding agents.

func (*Rules) Classify

func (r *Rules) Classify(c *Commit) (Origin, string)

Classify returns the origin of c and the assistant it names: the AI co-author's or agent's name ("Claude Opus 5", "Copilot"), "" for none. The order: a release plugin is automation; a known agent is an agent; a bot author is automation; an AI co-author or footer is assisted; a bot co-author (a bot's pull request merged by a person) is automation.

type Stats

type Stats struct {
	Additions int `json:"additions"`
	Deletions int `json:"deletions"`
	Files     int `json:"files"`
}

Stats are what a commit changed: lines added and removed, and files (-1 when GitHub does not say).

type Work

type Work uint8

Work is the reader's lens, the work that counts (P-42, P-43): a set of kinds. People's work is by hand or with an AI; automation (CI, dependency and release bots) and sweeps are maintenance.

const (
	WorkHand       Work = 1 << iota // a person, no trace of an AI
	WorkAI                          // assisted or by an agent
	WorkAutomation                  // automation and sweeps

	WorkTeam  = WorkHand | WorkAI         // people's work: what health counts
	WorkEvery = WorkTeam | WorkAutomation // every kind: the dashboard's default
)

func WorkOf

func WorkOf(ks []oapi.WorkKind, none Work) Work

WorkOf is the lens of the kinds a request names; none when it names no known kind.

func (Work) Counts

func (w Work) Counts(o Origin, person bool) bool

Counts reports whether a commit of origin o is work of the lens; person is false for a sweep's (and automation's).

Jump to

Keyboard shortcuts

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