feat(label): edit a label in a form without flags

label edit without flags on a terminal now opens a form with the label's
name, color, description and flags, like milestone edit and issue edit,
instead of failing; without a terminal it reports the shared "nothing to
edit" error. The help of issue and milestone close and reopen names its
commands without generating the text from the verb.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 00:17:08 +02:00
1 parent f6a0d18b8a
commit 5d2f2d83eb
6 files changed
+143 -8

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package terminal
import (
"context"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func TestLabelFormStartsFromCurrentValues(t *testing.T) {
p, _ := testPrompter(strings.NewReader("\r\r\r\r\r"))
current := LabelFormValues{Name: "bug", Color: "#EE0701", Description: "Broken", Exclusive: true}
values, err := p.EditLabel(context.Background(), `Editing label "bug" in alice/x`, current)
require.NoError(t, err)
require.Equal(t, LabelFormValues{Name: "bug", Color: "EE0701", Description: "Broken", Exclusive: true}, values)
}
func TestLabelFormMarksNameRequired(t *testing.T) {
p, rendered := accessiblePrompter(t, "bug\nee0701\n\nn\nn\n")
values, err := p.EditLabel(context.Background(), "", LabelFormValues{})
require.NoError(t, err)
require.Contains(t, rendered.String(), "Label name (required):")
require.Equal(t, "bug", values.Name)
}