MCPcopy Create free account
hub / github.com/git-bug/git-bug / runBugNew

Function runBugNew

commands/bug/bug_new.go:44–76  ·  view source on GitHub ↗
(env *execenv.Env, opts bugNewOptions)

Source from the content-addressed store, hash-verified

42}
43
44func runBugNew(env *execenv.Env, opts bugNewOptions) error {
45 var err error
46 if opts.messageFile != "" && opts.message == "" {
47 opts.title, opts.message, err = buginput.BugCreateFileInput(opts.messageFile)
48 if err != nil {
49 return err
50 }
51 }
52
53 if !opts.nonInteractive && opts.messageFile == "" && (opts.message == "" || opts.title == "") {
54 opts.title, opts.message, err = buginput.BugCreateEditorInput(env.Backend, opts.title, opts.message)
55
56 if err == buginput.ErrEmptyTitle {
57 env.Out.Println("Empty title, aborting.")
58 return nil
59 }
60 if err != nil {
61 return err
62 }
63 }
64
65 b, _, err := env.Backend.Bugs().New(
66 text.CleanupOneLine(opts.title),
67 text.Cleanup(opts.message),
68 )
69 if err != nil {
70 return err
71 }
72
73 env.Out.Printf("%s created\n", b.Id().Human())
74
75 return nil
76}

Callers 2

newBugNewCommandFunction · 0.85
TestBugNewFunction · 0.85

Calls 8

CleanupOneLineFunction · 0.92
CleanupFunction · 0.92
BugsMethod · 0.80
PrintlnMethod · 0.65
PrintfMethod · 0.65
IdMethod · 0.65
NewMethod · 0.45
HumanMethod · 0.45

Tested by 1

TestBugNewFunction · 0.68