MCPcopy Create free account
hub / github.com/cli/cli / printEditHistory

Function printEditHistory

pkg/cmd/issue/artifact/view/view.go:294–316  ·  view source on GitHub ↗

printEditHistory lists every version the API returned, newest first, with who saved it and when. "Current" marks the newest version, and "Viewing" marks the earlier version shown.

(ios *iostreams.IOStreams, now time.Time, versions []client.Version, viewing *client.Version)

Source from the content-addressed store, hash-verified

292// who saved it and when. "Current" marks the newest version, and "Viewing"
293// marks the earlier version shown.
294func printEditHistory(ios *iostreams.IOStreams, now time.Time, versions []client.Version, viewing *client.Version) error {
295 cs := ios.ColorScheme()
296 // The "Edit history" heading stands in for column headers.
297 tp := tableprinter.New(ios, tableprinter.NoHeader)
298 for i, v := range versions {
299 tp.AddField(strconv.Itoa(v.Version))
300 if v.CreatedAt != nil {
301 tp.AddField(displayName(v.Actor))
302 tp.AddTimeField(now, *v.CreatedAt, cs.Muted)
303 } else {
304 tp.AddField(login(v.Actor))
305 tp.AddField("")
306 }
307 switch {
308 case i == 0:
309 tp.AddField("Current", tableprinter.WithColor(cs.CyanBold))
310 case viewing != nil && v.Version == viewing.Version:
311 tp.AddField("Viewing", tableprinter.WithColor(cs.CyanBold))
312 }
313 tp.EndRow()
314 }
315 return tp.Render()
316}
317
318// displayName returns a user's login for the terminal. A null user shows as
319// ghost, like a deleted user in gh pr view, so callers use it only when the

Callers 1

printHumanArtifactFunction · 0.85

Calls 6

NewFunction · 0.92
ColorSchemeMethod · 0.80
AddTimeFieldMethod · 0.80
displayNameFunction · 0.70
loginFunction · 0.70
RenderMethod · 0.65

Tested by

no test coverage detected