MCPcopy
hub / github.com/mislav/hub / Extract

Method Extract

github/message_builder.go:21–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19}
20
21func (b *MessageBuilder) Extract() (title, body string, err error) {
22 content := b.Message
23
24 if b.Edit {
25 b.editor, err = NewEditor(b.Filename, b.Title, content)
26 if err != nil {
27 return
28 }
29 for _, section := range b.commentedSections {
30 b.editor.AddCommentedSection(section)
31 }
32 content, err = b.editor.EditContent()
33 if err != nil {
34 return
35 }
36 } else {
37 nl := regexp.MustCompile(`\r?\n`)
38 content = nl.ReplaceAllString(content, "\n")
39 }
40
41 parts := strings.SplitN(content, "\n\n", 2)
42 if len(parts) >= 1 {
43 title = strings.TrimSpace(strings.Replace(parts[0], "\n", " ", -1))
44 }
45 if len(parts) >= 2 {
46 body = strings.TrimSpace(parts[1])
47 }
48
49 if title == "" {
50 defer b.Cleanup()
51 }
52
53 return
54}
55
56func (b *MessageBuilder) Cleanup() {
57 if b.editor != nil {

Callers 7

createReleaseFunction · 0.95
editReleaseFunction · 0.95
pullRequestFunction · 0.95
createIssueFunction · 0.95
updateIssueFunction · 0.95
reportTitleAndBodyFunction · 0.95

Calls 5

CleanupMethod · 0.95
NewEditorFunction · 0.85
EditContentMethod · 0.80
ReplaceMethod · 0.80
AddCommentedSectionMethod · 0.45

Tested by 1