Documentation
¶
Overview ¶
Package render formats gitscan command results for output. It is not part of the gogit library's public API — cmd/*.go calls into it so the formatting logic can be unit tested without invoking Cobra or capturing os.Stdout.
Index ¶
- Variables
- func ApplyTimezone(commits []gogit.Commit, tz string) ([]gogit.Commit, error)
- func Commits(w io.Writer, format string, reports []CommitReport) error
- func Dep(w io.Writer, results []scanner.RepoResult, opts DepOptions)
- func Order(w io.Writer, sorted []scanner.RepoResult, allResults []scanner.RepoResult)
- func Scan(w io.Writer, results []scanner.RepoResult, opts ScanOptions) error
- func Since(w io.Writer, results []scanner.RepoResult, opts SinceOptions)
- type CommitReport
- type DepOptions
- type ScanOptions
- type SinceOptions
Constants ¶
This section is empty.
Variables ¶
var CommitFormats = []string{"table", "markdown", "json"}
CommitFormats lists the format values Commits accepts.
var CommitTimezones = []string{"original", "local", "utc"}
CommitTimezones lists the --tz values ApplyTimezone accepts.
var ScanFormats = []string{"list", "table"}
ScanFormats lists the format values Scan accepts.
Functions ¶
func ApplyTimezone ¶
ApplyTimezone returns a copy of commits with each CommitDate converted per tz: "original" (or "") leaves each commit's own recorded offset untouched, "local" converts to the calling machine's local timezone, and "utc" converts to UTC.
func Commits ¶ added in v0.10.0
func Commits(w io.Writer, format string, reports []CommitReport) error
Commits renders a set of per-repo CommitReports to w in the given format: "table" (aligned columns via text/tabwriter, for direct terminal reading), "markdown" (copy-pasteable GitHub-flavored tables), or "json" (structured envelope, for agents).
The output shape is invariant in the number of repositories: a single repository is simply a set of one, so callers and JSON consumers never have to branch on how many repos were reported. In multi-repo output, repos with no matching commits (and no error) are omitted from the human-readable formats; the summary always reflects every repo scanned.
func Dep ¶
func Dep(w io.Writer, results []scanner.RepoResult, opts DepOptions)
Dep renders gitscan dep's report to w: results sorted by name, filtered to those matching opts.ModulePath (per RepoResult.MatchesDependency), followed by a summary.
func Order ¶
func Order(w io.Writer, sorted []scanner.RepoResult, allResults []scanner.RepoResult)
Order renders gitscan order's topological update-order report to w. sorted is the (already topologically-sorted and filtered) list to display; allResults is the full result set used to look up internal dependency names for each row.
func Scan ¶
func Scan(w io.Writer, results []scanner.RepoResult, opts ScanOptions) error
Scan renders gitscan's root issue-scan report to w: results sorted by name, one row per repo that has an issue (or every repo, if opts.ShowClean), followed by an optional summary.
func Since ¶
func Since(w io.Writer, results []scanner.RepoResult, opts SinceOptions)
Since renders gitscan since's report to w: results sorted by name, filtered to those modified within opts.Duration (further AND-filtered by opts.DepFilter/opts.UnpushedOnly when set), followed by a summary.
Types ¶
type CommitReport ¶ added in v0.10.0
type CommitReport struct {
Repo string
// Branch is the repository's current branch (or "HEAD" when detached),
// shown in the header so a report is never read against the wrong
// checkout — e.g. "no upstream configured" on a fresh feature branch is
// easy to misread as "main has unpushed work" without it. Empty when the
// branch could not be determined (surfaced via Err instead).
Branch string
// Mode selects the per-repo header and JSON "mode" value:
// "unpushed" - commits ahead of Ref (the push baseline)
// "unpushed-all" - no push baseline; every local commit is pending
// "since-commit" - commits after the explicit Ref hash
// "pushed" - commits already pushed, read from Ref (the baseline)
Mode string
// Ref is the baseline the commits are measured against: an upstream or
// remote-tracking ref, or an explicit commit hash. Empty when Mode is
// "unpushed-all", or "pushed" with no push target.
Ref string
Commits []gogit.Commit
// Err, when non-empty, records why this repository could not be read.
Err string
}
CommitReport describes a labeled list of commits from one repository, as produced by the pending and pushed commands. The rendered table/markdown/ json bodies are identical across modes; only the per-repo header differs.
type DepOptions ¶
type DepOptions struct {
ModulePath string
DirectOnly bool
Prefix bool
Recurse bool // include the nested-go.mod-count annotation
}
DepOptions configures Dep's filtering and output.
type ScanOptions ¶
type ScanOptions struct {
Format string // "list" (default) or "table"
ShowClean bool // also print repos with no issues
ShowSummary bool // print the summary block at the end
CheckWorkflows bool // include workflow compliance columns/summary
}
ScanOptions configures Scan's output.
type SinceOptions ¶
type SinceOptions struct {
Duration time.Duration
DurationLabel string // the original duration string, for the summary line
DepFilter string // AND-combined with the modification-time filter
UnpushedOnly bool // AND-combined with the modification-time filter
}
SinceOptions configures Since's filtering and output.