forked from NYANDEV/forgejo
Reduce duplicate and useless code in options (#23369)
Avoid maintaining two copies of code, some functions can be used with both `bindata` and `no bindata`. And removed `GetRepoInitFile`, it's useless now. `Readme`/`Gitignore`/`License`/`Labels` will clean the name and use custom files when available.
This commit is contained in:
parent
a12f575737
commit
090e753923
6 changed files with 74 additions and 158 deletions
|
@ -36,17 +36,17 @@ func (err ErrTemplateLoad) Error() string {
|
|||
// GetTemplateFile loads the label template file by given name,
|
||||
// then parses and returns a list of name-color pairs and optionally description.
|
||||
func GetTemplateFile(name string) ([]*Label, error) {
|
||||
data, err := options.GetRepoInitFile("label", name+".yaml")
|
||||
data, err := options.Labels(name + ".yaml")
|
||||
if err == nil && len(data) > 0 {
|
||||
return parseYamlFormat(name+".yaml", data)
|
||||
}
|
||||
|
||||
data, err = options.GetRepoInitFile("label", name+".yml")
|
||||
data, err = options.Labels(name + ".yml")
|
||||
if err == nil && len(data) > 0 {
|
||||
return parseYamlFormat(name+".yml", data)
|
||||
}
|
||||
|
||||
data, err = options.GetRepoInitFile("label", name)
|
||||
data, err = options.Labels(name)
|
||||
if err != nil {
|
||||
return nil, ErrTemplateLoad{name, fmt.Errorf("GetRepoInitFile: %w", err)}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue