diff --git a/internal/cli/issue_create.go b/internal/cli/issue_create.go index b853f79..bff5186 100644 --- a/internal/cli/issue_create.go +++ b/internal/cli/issue_create.go @@ -22,7 +22,7 @@ func newIssueCreateCommand(service issueCreateService) *cobra.Command { Short: "Create an issue on a Tangled repository", Long: `Create an issue on a Tangled repository. When title and body are omitted, tg opens $EDITOR. The edited document's first line is the title, its second line -must be blank, and the remaining text is the required body.`, +must be blank, and the remaining text is an optional body.`, Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() diff --git a/internal/cli/issue_editor.go b/internal/cli/issue_editor.go index e8d5231..e8eb69d 100644 --- a/internal/cli/issue_editor.go +++ b/internal/cli/issue_editor.go @@ -13,7 +13,7 @@ const ( titledDraftTemplate = "\n\n" + titledDraftSentinel + "\n" + "\n" issueDraftTemplate = "\n\n" + titledDraftSentinel + "\n" + - "\n" + "\n" ) var errTitledDraftCanceled = errors.New("title and body creation canceled") @@ -41,14 +41,7 @@ func editTitledDraft(ctx context.Context, kind, pattern, template string, input } func editIssueDraft(ctx context.Context, input io.Reader, output, errorOutput io.Writer) (titledDraft, error) { - draft, err := editTitledDraft(ctx, "issue", "tg-issue-*.md", issueDraftTemplate, input, output, errorOutput) - if err != nil { - return titledDraft{}, err - } - if strings.TrimSpace(draft.Body) == "" { - return titledDraft{}, fmt.Errorf("parse issue draft: body must not be empty; draft saved to %s", draft.Path) - } - return draft, nil + return editTitledDraft(ctx, "issue", "tg-issue-*.md", issueDraftTemplate, input, output, errorOutput) } func parseTitledDraft(document string) (string, string, error) { diff --git a/internal/cli/issue_editor_test.go b/internal/cli/issue_editor_test.go index 485ca79..552e860 100644 --- a/internal/cli/issue_editor_test.go +++ b/internal/cli/issue_editor_test.go @@ -77,7 +77,7 @@ func TestEditIssueDraftLifecycle(t *testing.T) { }{ {name: "valid draft", document: "Bug report\n\nDetails\n", wantTitle: "Bug report", wantBody: "Details", wantSaved: true}, {name: "canceled draft", document: issueDraftTemplate, wantError: errTitledDraftCanceled.Error()}, - {name: "empty body", document: "Bug report\n\n", wantError: "body must not be empty", wantSaved: true}, + {name: "empty body", document: "Bug report\n\n", wantTitle: "Bug report", wantSaved: true}, {name: "malformed draft", document: "Bug report\nDetails\n", wantError: "second line must be empty", wantSaved: true}, {name: "failed editor", document: "Unfinished\n\nDraft\n", exitStatus: 23, wantError: "run issue editor", wantSaved: true}, }