mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix(label): keep exclusive and archived flags in label export
label export wrote "#7057ff good first issue ;" with a dangling separator and dropped the exclusive and archived flags, so an export and re-import lost them. Rows now omit an empty description and end in " ;exclusive", " ;archived" or both when a label has those flags; label create --file reads them back. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
3 files changed
+64
-5
No files matched your search
@@ -23,6 +23,9 @@ func TestLabelFileRoundTrip(t *testing.T) {
|
||||
{Name: "bug", Color: "ff0000", Description: "Something is broken"},
|
||||
{Name: "kind/feature request", Color: "#00FF00", Description: "Wanted; maybe"},
|
||||
{Name: "#hash", Color: "0000ff"},
|
||||
{Name: "priority/high", Color: "7057ff", Exclusive: true},
|
||||
{Name: "old", Color: "cccccc", Description: "Retired; kept", Exclusive: true, Archived: true},
|
||||
{Name: "flag-like", Color: "cccccc", Description: "ends in;archived text"},
|
||||
} {
|
||||
row, err := formatLabel(label)
|
||||
require.NoError(t, err, label.Name)
|
||||
@@ -32,6 +35,19 @@ func TestLabelFileRoundTrip(t *testing.T) {
|
||||
require.Equal(t, label.Name, *parsed[0].Name)
|
||||
require.Equal(t, strings.TrimPrefix(label.Color, "#"), *parsed[0].Color)
|
||||
require.Equal(t, label.Description, *parsed[0].Description)
|
||||
require.Equal(t, label.Exclusive, parsed[0].Exclusive != nil && *parsed[0].Exclusive, row)
|
||||
require.Equal(t, label.Archived, parsed[0].Archived != nil && *parsed[0].Archived, row)
|
||||
}
|
||||
for label, row := range map[services.Label]string{
|
||||
{Name: "good first issue", Color: "7057ff"}: "#7057ff good first issue\n",
|
||||
{Name: "bug", Color: "ee0701", Description: "Broken"}: "#ee0701 bug ;Broken\n",
|
||||
{Name: "priority/high", Color: "7057ff", Exclusive: true}: "#7057ff priority/high ; ;exclusive\n",
|
||||
{Name: "old", Color: "cccccc", Description: "Retired", Archived: true}: "#cccccc old ;Retired ;archived\n",
|
||||
{Name: "both", Color: "cccccc", Exclusive: true, Archived: true}: "#cccccc both ; ;exclusive,archived\n",
|
||||
} {
|
||||
formatted, err := formatLabel(label)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, row, formatted)
|
||||
}
|
||||
for _, label := range []services.Label{
|
||||
{Name: "", Color: "ff0000"},
|
||||
|
||||
Reference in new issue
Block a user