Documentation
¶
Overview ¶
Package standup groups one person's activity in a checkout by task, for `f10 standup`. Group and Merge are pure, so the same history gives the same report byte for byte. The JSON shape (Standup) is a contract documented in docs/cli.md; a breaking change bumps Schema.
Index ¶
- Constants
- func ActivityTimes(r Report) []time.Time
- func CheckGlob(pattern string) error
- func Contributed(s Standup) bool
- func Days(times []time.Time, loc *time.Location) []string
- func Detail(ctx context.Context, in *Input, from time.Time)
- func Glob(pattern, p string) bool
- func NeedsCI(c Commit, extra []string) bool
- func Resolve(now, since time.Time, week bool, last *Last) (time.Time, string)
- func SetDays(s *Standup, loc *time.Location)
- func UpkeepPath(p string) bool
- type Action
- type Activity
- type Blocked
- type CI
- type Commit
- type Day
- type Drive
- type File
- type ForcePush
- type HostPR
- type Input
- type Last
- type Ledger
- type LedgerNote
- type Other
- type PR
- type PRCommit
- type Project
- type Repo
- type Report
- type Review
- type ReviewedPR
- type Source
- type Standup
- type Task
- type Tracker
- type User
Constants ¶
const ( BlockedAsk = "ask" BlockedHalt = "halt" BlockedFailed = "failed" )
The kinds a blocked task waits on.
const ( ActivityPlan = "plan" ActivityDebug = "debug" ActivitySpike = "spike" ActivityReview = "review" ActivityJudge = "judge" )
The kinds of activity a step leaves without a commit.
const ( PeriodLastStandup = "last_standup" PeriodLastWorkingDay = "last_working_day" PeriodSince = "since" PeriodWeek = "week" )
How a report's start was chosen, echoed as its period.
const ( StateStarted = "started" StateInProgress = "in progress" StateInReview = "in review" StateShipped = "shipped" StateClosed = "closed" )
Where a PR or a task ended the period, least advanced first; Closed never decides a task's state while anything else does.
const ( HostOpen = "open" HostMerged = "merged" HostClosed = "closed" )
The host states a PR arrives in, normalised from gh's and glab's spellings.
const ( ActionReviewed = "reviewed" ActionMerged = "merged" )
const ( ClassWork = "work" ClassUpkeep = "upkeep" )
The class of one item of activity, and of a task as a whole.
const ( UpkeepBaseMerge = "base-merge" // a merge of the base branch into the task's UpkeepRebase = "rebase" // a force-push that kept every patch UpkeepFiles = "files" // only lockfiles, generated files or snapshots UpkeepCIFix = "ci-fix" // a small test-only change after red CI )
Why an item is upkeep.
const LedgerScope = "this machine only"
LedgerScope is the one value the JSON's ledger note holds: the ledger is local, so on a second machine its half of the report is partial.
const Schema = 2
Schema is the version of the report's JSON shape.
Variables ¶
This section is empty.
Functions ¶
func ActivityTimes ¶
ActivityTimes is every time the user did something in the report's period.
func CheckGlob ¶
CheckGlob refuses a pattern Glob cannot read: a malformed segment, or an absolute path, since paths are relative to the repository root.
func Contributed ¶ added in v0.61.0
Contributed reports a report the ledger added anything to.
func Detail ¶ added in v0.66.0
Detail reads what Collect left out, for the own PRs updated since from: their commits and force-pushes, then the CI of the commits since from. A push moves a PR's updatedAt, so a PR updated earlier has no activity since. A PR whose read fails is a warning, and the report still prints.
func Glob ¶
Glob matches the way .gitignore reads a pattern: no slash matches the base name anywhere, a slash the whole path, `**` any number of directories.
func NeedsCI ¶
NeedsCI reports whether c is a CI fix if its parent's CI was red: the collector asks the host only for these.
func Resolve ¶
Resolve picks the period's start. A standup reported earlier today gives its own start again, so a second report the same day is not empty; with nothing stored it returns PeriodLastWorkingDay and a zero time, for the caller to settle with calendar.LastActiveWorkday once it has the activity.
func SetDays ¶ added in v0.34.0
SetDays fills in the local dates with activity, report-wide and per task and reviewed PR, from the same times, so a task's day is always one of the report's. It runs after Merge, so a merged task gets every repository's days.
func UpkeepPath ¶ added in v0.45.0
UpkeepPath reports a path nobody writes by hand: a lockfile, generated code or a snapshot.
Types ¶
type Activity ¶ added in v0.61.0
type Activity struct {
At time.Time `json:"at"`
Kind string `json:"kind"`
Text string `json:"text"`
}
Activity is one step run in the period that left no commit.
type Blocked ¶ added in v0.61.0
type Blocked struct {
Kind string `json:"kind"`
Since time.Time `json:"since"`
Text string `json:"text"`
// LaterCommit is an ask's first task commit after it: the ask stays
// open in the ledger, but that commit may have settled it
LaterCommit string `json:"later_commit,omitempty"`
}
Blocked is what a task waits on at the end of the period, and since when.
type Commit ¶
type Commit struct {
SHA string `json:"sha"`
Subject string `json:"subject"`
At time.Time `json:"at"` // author date
Branch string `json:"branch"` // the branch it was reached from, remote prefix dropped
Parents []string `json:"parents"`
Class string `json:"class"`
Upkeep string `json:"upkeep,omitempty"`
Repo string `json:"repo"`
// What upkeep.go decides the class from, collected beside the commit.
Files []File `json:"-"`
BaseMerge bool `json:"-"` // a merge whose second parent is on the base's first-parent line
ParentCI *CI `json:"-"` // nil unless asked and the host had checks
}
A Commit is one commit the user authored in the period.
type Day ¶ added in v0.34.0
A Day is a local date a task had activity on, with that day's class alone: work on Monday and a base merge on Tuesday is work on one, upkeep on the other.
type Drive ¶ added in v0.61.0
type Drive struct {
Repo string `json:"repo"`
Number int `json:"number"`
Tasks int `json:"tasks"`
Shipped int `json:"shipped"`
NeedsYou int `json:"needs_you"`
}
Drive is one drive active in the period, by its outcome so far.
func DriveSummaries ¶ added in v0.61.0
func DriveSummaries( repo string, drives []*drivestore.Record, since, until time.Time, active, shipped map[string]bool, ) []Drive
DriveSummaries is each drive that ran in the period, by its outcome so far. A task the report has shipped counts as shipped whatever its outcome, because a drive that stops before finish exits non-zero on a PR a person merges later. shipped is keyed by the upper-cased task id.
type File ¶
type File struct {
Path string
Added int
Deleted int
Binary bool
Generated bool // marked linguist-generated, or carrying Go's generated header
}
A File is one path a commit changed, as numstat counts it.
type ForcePush ¶
type ForcePush struct {
At time.Time `json:"at"`
Before string `json:"before"`
After string `json:"after"`
Class string `json:"class"`
Upkeep string `json:"upkeep,omitempty"`
SamePatches *bool `json:"-"`
}
A ForcePush is one force-push to the user's own PR. SamePatches is nil when either side is not in the local object store.
type HostPR ¶
type HostPR struct {
Number int
Title string
URL string
Status string // HostOpen, HostMerged or HostClosed
Draft bool
Empty bool // no changes yet: no changed files on GitHub, no commits on GitLab
Head string
Base string
Author string
CreatedAt time.Time
MergedAt time.Time // zero unless merged
MergedBy string
Commits []PRCommit // the commits the host lists for it; read for the user's own PRs only
MergeSHA []string // the merge and squash commits it landed as
Reviews []Review // read for other people's PRs only
ForcePushes []ForcePush // the user's own, on their own PRs
}
A HostPR is a PR or MR as the host reported it, before grouping.
type Input ¶
type Input struct {
Prefix string // task id prefix; empty matches no id
Since time.Time
Repo string // the repository's name, stamped on every PR and commit
Project string // the project Merge lists it under: the repo, or a shared tracker's prefix
Tracker Tracker // the tracker its task ids belong to
Checkout string
Host string // "gh", "glab", or "" with no host
DefaultBranch string // local name, "main"
User User
Commits []Commit // the user's, from git
PRs []HostPR // the user's own and the ones they reviewed or merged
Bases map[string]string // head branch to the base branch `f10 start --after` recorded
UpkeepPaths []string // the project's globs, on top of the default upkeep paths
Ledger *Ledger // nil: no ledger read
Warnings []string // what the host failed to give, the report printed without it
// contains filtered or unexported fields
}
Input is everything Group needs, already collected.
type Ledger ¶ added in v0.61.0
type Ledger struct {
Events []ledger.Event
// WorktreeOf is the path f10 start gives a branch's worktree, so rows
// from a worktree removed since still count
WorktreeOf func(branch string) string
Checkouts []string // the main checkout and its worktrees today
Drives []*drivestore.Record
Until time.Time // the read time, the period's end
}
Ledger is what the ledger and the drive records add to one checkout's report. Events are the project's sessions active in the period (a SinceScope read); Group keeps only the person's.
type LedgerNote ¶ added in v0.61.0
LedgerNote says the ledger half is local, and whether it added anything.
type PR ¶
type PR struct {
Repo string `json:"repo"`
Number int `json:"number"`
Title string `json:"title"`
URL string `json:"url"`
State string `json:"state"`
Draft bool `json:"draft"`
Head string `json:"head"`
Base string `json:"base"`
BasePR int `json:"base_pr,omitempty"`
CreatedAt time.Time `json:"created_at"`
MergedAt *time.Time `json:"merged_at,omitempty"`
Commits []Commit `json:"commits"`
ForcePushes []ForcePush `json:"force_pushes"`
}
PR is one of the user's PRs in the report.
type PRCommit ¶
A PRCommit is one commit a PR lists. A rebase merge lands it on the default branch under a new sha, keeping its author date and subject.
type Project ¶ added in v0.34.0
type Project struct {
Name string `json:"name"`
Tracker Tracker `json:"tracker"`
Repos []Repo `json:"repos"`
Tasks []Task `json:"tasks"`
Other Other `json:"other"`
Reviewed []ReviewedPR `json:"reviewed"`
Drives []Drive `json:"drives"`
}
A Project is the activity on one tracker, across its repositories.
type Repo ¶ added in v0.34.0
type Repo struct {
Name string `json:"name"`
Checkout string `json:"checkout"`
Host *string `json:"host"`
User User `json:"user"`
}
A Repo is one repository a project's activity came from.
type Report ¶
type Report struct {
Since time.Time
Repo string
Project string
Tracker Tracker
Checkout string
Host *string
User User
Tasks []Task
Other Other
Reviewed []ReviewedPR
Drives []Drive
Warnings []string
}
Report is the activity in one repository, before Merge.
type ReviewedPR ¶
type ReviewedPR struct {
Repo string `json:"repo"`
Number int `json:"number"`
Title string `json:"title"`
URL string `json:"url"`
State string `json:"state"`
Author string `json:"author"`
Actions []Action `json:"actions"`
Days []string `json:"days"` // local dates of the actions; the command sets it
}
ReviewedPR is someone else's PR the user reviewed or merged.
type Source ¶ added in v0.58.0
type Source struct {
Dir string // the checkout
Main string // the main checkout, where branch records live
Prefix string // the task id prefix
Upkeep []string // project.md's upkeep globs
Host *forge.Host // nil: no host CLI for this checkout
}
Source is the checkout a standup reads.
type Standup ¶ added in v0.34.0
type Standup struct {
Schema int `json:"schema"`
Since time.Time `json:"since"`
Period string `json:"period,omitempty"` // how since was chosen
Days []string `json:"days"` // local dates with activity; SetDays sets it
Projects []Project `json:"projects"`
// Ledger is set when a ledger was read: its half is this machine's alone
Ledger *LedgerNote `json:"ledger,omitempty"`
// Warnings name what the host failed to give after a retry. The report
// printed without it
Warnings []string `json:"warnings"`
}
Standup is the report `f10 standup --json` prints: one period, the projects in the order their first repository was given.
type Task ¶
type Task struct {
ID string `json:"id"`
Title string `json:"title"`
State string `json:"state"`
Class string `json:"class"`
After string `json:"after,omitempty"`
// Riders are the tasks a bundle's branch ships beside this one, its lead
Riders []string `json:"riders,omitempty"`
Days []Day `json:"days"` // the command sets it
PRs []PR `json:"prs"`
Commits []Commit `json:"commits"` // commits on no PR of the user's
// from the ledger: what the task waits on, the steps that left no
// commit, where the run left it, the drive running it, and its time
Blocked *Blocked `json:"blocked,omitempty"`
Activity []Activity `json:"activity"`
Stage string `json:"stage,omitempty"`
Driven int `json:"driven,omitempty"`
ActiveMinutes int `json:"active_minutes"`
Ledger bool `json:"-"` // one of the person's ledger rows names it
}
Task is the activity carrying one task id.
type Tracker ¶ added in v0.34.0
type Tracker struct {
Kind string `json:"kind"`
Prefix string `json:"prefix"`
Key string `json:"-"`
}
A Tracker is where a repository's task ids live; repositories with the same Key share ids. The command sets Key, since only it knows whether a tracker is the repository's own issues.