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

Function metadataLine

pkg/cmd/issue/artifact/view/view.go:267–289  ·  view source on GitHub ↗

metadataLine describes the artifact under its name: its number, type, creator and last editor, or for an earlier version, that version's number and who saved it. A part whose time is null is left out, and so is the update of an artifact that was never edited.

(a client.Artifact, viewing *client.Version, now time.Time)

Source from the content-addressed store, hash-verified

265// and who saved it. A part whose time is null is left out, and so is the
266// update of an artifact that was never edited.
267func metadataLine(a client.Artifact, viewing *client.Version, now time.Time) string {
268 parts := []string{fmt.Sprintf("Artifact %d", a.Number), a.Type}
269
270 if viewing != nil {
271 parts = append(parts, fmt.Sprintf("Version %d", viewing.Version))
272 if viewing.CreatedAt != nil {
273 action := "updated"
274 if viewing.Version == 1 {
275 action = "created"
276 }
277 parts = append(parts, fmt.Sprintf("%s %s %s", displayName(viewing.Actor), action, text.FuzzyAgo(now, *viewing.CreatedAt)))
278 }
279 return strings.Join(parts, " • ")
280 }
281
282 if a.CreatedAt != nil {
283 parts = append(parts, fmt.Sprintf("%s created %s", displayName(a.Creator), text.FuzzyAgo(now, *a.CreatedAt)))
284 }
285 if a.UpdatedAt != nil && (a.CreatedAt == nil || !a.UpdatedAt.Equal(*a.CreatedAt)) {
286 parts = append(parts, fmt.Sprintf("%s updated %s", displayName(a.UpdatedByActor), text.FuzzyAgo(now, *a.UpdatedAt)))
287 }
288 return strings.Join(parts, " • ")
289}
290
291// printEditHistory lists every version the API returned, newest first, with
292// who saved it and when. "Current" marks the newest version, and "Viewing"

Callers 1

printHumanArtifactFunction · 0.85

Calls 4

FuzzyAgoFunction · 0.92
JoinMethod · 0.80
EqualMethod · 0.80
displayNameFunction · 0.70

Tested by

no test coverage detected