Documentation
¶
Index ¶
- func AppendEntries(project string, entries []Entry) error
- func AppendEntriesToPath(path string, entries []Entry) error
- func CountForTicket(entries []Entry, ticketID string) int
- func ExtractTicketActions(message string) map[string]string
- func FirstLine(s string) string
- func GetDiffStats(repoPath, sha string) (files []string, added, removed int, branch string, err error)
- func GetParentCommitTS(repoPath, sha string) string
- func GroupByTicket(entries []Entry) map[string][]Entry
- func IsLiveCommit(ts string) bool
- func JournalPath(project string) (string, error)
- func LoadJournalState(path string) (map[string]struct{}, string, error)
- func ResolveActions(projectName string, actions map[string]string) map[string]string
- func ResolveRef(projectName, ref string) string
- func ResolveStableBranchName(repoPath, sha string) string
- func StatePath(project string) (string, error)
- func WorkDurationSeconds(started, ended string) int
- type EffortSummary
- type Entry
- type GitCommit
- type WatchCycleResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendEntries ¶
AppendEntries appends entries to the project's commits.jsonl, creating parent directories if needed. Entries whose SHA+Ticket pair already exists in the file are skipped.
func AppendEntriesToPath ¶
AppendEntriesToPath appends entries to a specific JSONL path with dedup.
func CountForTicket ¶
CountForTicket counts entries for a specific ticket ID.
func ExtractTicketActions ¶
ExtractTicketActions parses a commit message and returns a map of ticket ID to action. Bracket refs [ticket-id] produce action "ref". Closes:/Fixes: prefixes followed by bracket refs produce action "close".
func GetDiffStats ¶
func GetDiffStats(repoPath, sha string) (files []string, added, removed int, branch string, err error)
GetDiffStats runs git diff-tree --numstat for a commit and returns changed files, total lines added, total lines removed, and the branch name.
func GetParentCommitTS ¶
GetParentCommitTS returns the author date of the parent commit (sha^), used as a work_started proxy. Returns empty string on any error.
func GroupByTicket ¶
GroupByTicket groups entries by ticket ID into a map.
func IsLiveCommit ¶
IsLiveCommit returns true if the commit timestamp is within the last 60 seconds.
func JournalPath ¶
JournalPath returns ~/.ticket/state/<project>/commits.jsonl.
func LoadJournalState ¶
LoadJournalState reads existing SHAs and the last SHA from a journal file.
func ResolveActions ¶
ResolveActions keys one commit's extracted actions by the ID each is journalled under. It collapses the two forms of one ticket, since a single commit can carry both — `[project/foo-1234] Closes: [foo-1234]` — and two entries for one commit and ticket would disagree about the action. A close outranks a plain ref, as it already does per ref in ExtractTicketActions.
func ResolveRef ¶
ResolveRef reduces a ref naming projectName to its bare ID, and leaves any other ref alone. A project's journal file and its store are both scoped to that one project, and every entry written before namespaced IDs existed is bare, so keying the two forms apart would split one ticket's history in two. A ref carrying another project's namespace passes through — a project-scoped store cannot resolve it.
Every writer of a journal entry goes through this: the watch cycle and `tk recompute`, which rebuilds the same file from the same extraction.
func ResolveStableBranchName ¶
ResolveStableBranchName returns a single stable branch label for a commit. Returns empty string if the commit belongs to zero or multiple branches.
func WorkDurationSeconds ¶
WorkDurationSeconds computes the duration in seconds between two RFC3339 timestamps. Returns 0 if either is empty or unparseable.
Types ¶
type EffortSummary ¶
EffortSummary holds aggregated diff stats for a set of journal entries.
func Effort ¶
func Effort(entries []Entry) EffortSummary
Effort computes aggregated diff stats from a slice of journal entries.
func (EffortSummary) String ¶
func (e EffortSummary) String() string
String returns a human-readable effort summary, or empty string if no data.
type Entry ¶
type Entry struct {
SHA string `json:"sha"`
Ticket string `json:"ticket"`
Repo string `json:"repo"`
TS string `json:"ts"`
Msg string `json:"msg"`
Author string `json:"author"`
Action string `json:"action"`
FilesChanged []string `json:"files_changed,omitempty"`
LinesAdded int `json:"lines_added,omitempty"`
LinesRemoved int `json:"lines_removed,omitempty"`
Branch string `json:"branch,omitempty"`
WorkStarted string `json:"work_started,omitempty"`
WorkEnded string `json:"work_ended,omitempty"`
DurationSecs int `json:"duration_seconds,omitempty"`
}
Entry represents a single commit-to-ticket link in the journal JSONL file.
func FilterByTickets ¶
FilterByTickets returns entries whose Ticket is in the given set of IDs.
func ReadEntries ¶
ReadEntries loads all commit journal entries for the given project. Malformed lines are silently skipped. Missing file returns empty slice.
func ReadEntriesFromPath ¶
ReadEntriesFromPath loads entries from a specific JSONL file path.
type GitCommit ¶
GitCommit represents a parsed git log entry.
func CollectCommits ¶
CollectCommits runs git log and returns commits in chronological order. If lastSHA is provided, returns commits after that SHA. If lastSHA is empty or the SHA range fails (history rewrite), falls back to --since=registeredAt.
type WatchCycleResult ¶
type WatchCycleResult struct {
Appended int
Closed int
// RetrospectFired counts the `loom retrospect` runs the cycle started;
// RetrospectSeeded the closes it recorded without firing, which only the
// first cycle after the flag goes on can be nonzero.
RetrospectFired int
RetrospectSeeded int
Warnings []string
}
WatchCycleResult holds the outcome of a single watch cycle for a project.
func RunWatchCycle ¶
func RunWatchCycle(projectName string, cfg project.ProjectConfig, store ticket.Store) (WatchCycleResult, error)
RunWatchCycle processes new git commits for a project, extracts ticket references, computes diff stats, appends journal entries, optionally auto-closes tickets, and optionally hands each newly closed ticket to `loom retrospect`.