MCPcopy Index your code
hub / github.com/git-bug/git-bug / bugsOrgmodeFormatter

Function bugsOrgmodeFormatter

commands/bug/bug.go:279–356  ·  view source on GitHub ↗
(env *execenv.Env, excerpts []*cache.BugExcerpt)

Source from the content-addressed store, hash-verified

277}
278
279func bugsOrgmodeFormatter(env *execenv.Env, excerpts []*cache.BugExcerpt) error {
280 // see https://orgmode.org/manual/Tags.html
281 orgTagRe := regexp.MustCompile("[^[:alpha:]_@]")
282 formatTag := func(l common.Label) string {
283 return orgTagRe.ReplaceAllString(l.String(), "_")
284 }
285
286 formatTime := func(time time.Time) string {
287 return time.Format("[2006-01-02 Mon 15:05]")
288 }
289
290 env.Out.Println("#+TODO: OPEN | CLOSED")
291
292 for _, b := range excerpts {
293 status := strings.ToUpper(b.Status.String())
294
295 var title string
296 if link, ok := b.CreateMetadata["github-url"]; ok {
297 title = fmt.Sprintf("[[%s][%s]]", link, b.Title)
298 } else {
299 title = b.Title
300 }
301
302 author, err := env.Backend.Identities().ResolveExcerpt(b.AuthorId)
303 if err != nil {
304 return err
305 }
306
307 var labels strings.Builder
308 labels.WriteString(":")
309 for i, l := range b.Labels {
310 if i > 0 {
311 labels.WriteString(":")
312 }
313 labels.WriteString(formatTag(l))
314 }
315 labels.WriteString(":")
316
317 env.Out.Printf("* %-6s %s %s %s: %s %s\n",
318 status,
319 b.Id().Human(),
320 formatTime(b.CreateTime()),
321 author.DisplayName(),
322 title,
323 labels.String(),
324 )
325
326 env.Out.Printf("** Last Edited: %s\n", formatTime(b.EditTime()))
327
328 env.Out.Printf("** Actors:\n")
329 for _, element := range b.Actors {
330 actor, err := env.Backend.Identities().ResolveExcerpt(element)
331 if err != nil {
332 return err
333 }
334
335 env.Out.Printf(": %s %s\n",
336 actor.Id().Human(),

Callers 1

runBugFunction · 0.85

Calls 11

ResolveExcerptMethod · 0.80
IdentitiesMethod · 0.80
StringMethod · 0.65
PrintlnMethod · 0.65
PrintfMethod · 0.65
IdMethod · 0.65
CreateTimeMethod · 0.65
DisplayNameMethod · 0.65
FormatMethod · 0.45
HumanMethod · 0.45
EditTimeMethod · 0.45

Tested by

no test coverage detected