Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom label option appears twice #23715

Closed
eeyrjmr opened this issue Mar 26, 2023 · 1 comment · Fixed by #23749
Closed

custom label option appears twice #23715

eeyrjmr opened this issue Mar 26, 2023 · 1 comment · Fixed by #23749
Labels
Milestone

Comments

@eeyrjmr
Copy link
Contributor

eeyrjmr commented Mar 26, 2023

Description

when adding a custom yaml label file, an option appears twice. the glob appears to be searching for files as well as file types

Gitea Version

1.19.0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

2023-03-26_14-03-1679838041

#pwd
/var/lib/gitea/custom/options/label

#ls
test.yaml

#cat test.yaml
labels:
  - name: "foo/bar"  # name of the label that will appear in the dropdown
    exclusive: true # whether to use the exclusive namespace for scoped labels. scoped delimiter is /
    color: aabbcc # hex colour coding
    description: Some label # long description of label intent
  - name: "foo/baz"  # name of the label that will appear in the dropdown
    exclusive: true # whether to use the exclusive namespace for scoped labels. scoped delimiter is /
    color: aabbcc # hex colour coding
    description: Some other label # long description of label intent

Git Version

2.40.0

Operating System

linux (gentoo)

How are you running Gitea?

rc-service

Database

None

@eeyrjmr
Copy link
Contributor Author

eeyrjmr commented Mar 26, 2023

so the issue is here:

func GetTemplateFile(name string) ([]*Label, error) {
data, err := options.Labels(name + ".yaml")
if err == nil && len(data) > 0 {
return parseYamlFormat(name+".yaml", data)
}
data, err = options.Labels(name + ".yml")
if err == nil && len(data) > 0 {
return parseYamlFormat(name+".yml", data)
}
data, err = options.Labels(name)
if err != nil {
return nil, ErrTemplateLoad{name, fmt.Errorf("GetRepoInitFile: %w", err)}
}
return parseLegacyFormat(name, data)
}

line39 passes but also line 49 is executed. These might need to be an embedded if/else on the err

zeripath added a commit to zeripath/gitea that referenced this issue Mar 27, 2023
…o options

The previous code did not remove the .yaml/.yml extension from label
files within the customPath. This would lead to duplicate lists of
labels.

Fix go-gitea#23715
Close go-gitea#23717

Signed-off-by: Andrew Thornton <art27@cantab.net>
lunny pushed a commit that referenced this issue Apr 10, 2023
Fix #23715

Other related PRs:

* #23717
* #23716
* #23719

This PR is different from others, it tries to resolve the problem fundamentally (and brings more benefits)

Although it looks like some more lines are added, actually many new lines are for tests.

----

Before, the code was just "guessing" the file type and try to parse them.

<details>

![image](https://user-images.githubusercontent.com/2114189/228002245-57d58e27-1078-4da9-bf42-5bc0b264c6ce.png)

</details>

This PR:

* Always remember the original option file names, and always use correct parser for them.

* Another benefit is that we can sort the Label Templates now (before there was a map, its key order is undefined)

![image](https://user-images.githubusercontent.com/2114189/228002432-931b9f18-3908-484b-a36b-04760c9ad132.png)
wxiaoguang added a commit to wxiaoguang/gitea that referenced this issue Apr 12, 2023
…23749)

Fix go-gitea#23715

Other related PRs:

* go-gitea#23717
* go-gitea#23716
* go-gitea#23719

This PR is different from others, it tries to resolve the problem fundamentally (and brings more benefits)

Although it looks like some more lines are added, actually many new lines are for tests.

----

Before, the code was just "guessing" the file type and try to parse them.

<details>

![image](https://user-images.githubusercontent.com/2114189/228002245-57d58e27-1078-4da9-bf42-5bc0b264c6ce.png)

</details>

This PR:

* Always remember the original option file names, and always use correct parser for them.

* Another benefit is that we can sort the Label Templates now (before there was a map, its key order is undefined)

![image](https://user-images.githubusercontent.com/2114189/228002432-931b9f18-3908-484b-a36b-04760c9ad132.png)
# Conflicts:
#	modules/label/parser.go
#	routers/web/org/setting.go
#	routers/web/repo/issue_label.go
#	templates/repo/create.tmpl
#	templates/repo/issue/labels/label_load_template.tmpl
@lunny lunny added this to the 1.19.1 milestone Apr 12, 2023
6543 pushed a commit that referenced this issue Apr 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.