BugTitleEditorInput will open the default editor in the terminal with a template for the user to fill. The file is then processed to extract a title.
(repo repository.RepoCommonStorage, preTitle string)
| 146 | // BugTitleEditorInput will open the default editor in the terminal with a |
| 147 | // template for the user to fill. The file is then processed to extract a title. |
| 148 | func BugTitleEditorInput(repo repository.RepoCommonStorage, preTitle string) (string, error) { |
| 149 | template := fmt.Sprintf(bugTitleTemplate, preTitle) |
| 150 | |
| 151 | raw, err := input.LaunchEditorWithTemplate(repo, messageFilename, template) |
| 152 | if err != nil { |
| 153 | return "", err |
| 154 | } |
| 155 | |
| 156 | lines := strings.Split(raw, "\n") |
| 157 | |
| 158 | var title string |
| 159 | for _, line := range lines { |
| 160 | if strings.HasPrefix(line, "#") { |
| 161 | continue |
| 162 | } |
| 163 | trimmed := strings.TrimSpace(line) |
| 164 | if trimmed == "" { |
| 165 | continue |
| 166 | } |
| 167 | title = trimmed |
| 168 | break |
| 169 | } |
| 170 | |
| 171 | if title == "" { |
| 172 | return "", ErrEmptyTitle |
| 173 | } |
| 174 | |
| 175 | return title, nil |
| 176 | } |
| 177 | |
| 178 | const queryTemplate = `%s |
| 179 |
nothing calls this directly
no test coverage detected