mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-22 11:00:01 +02:00
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
|
@ -136,7 +136,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
|
|||
}
|
||||
|
||||
// README
|
||||
data, err := options.GetRepoInitFile("readme", opts.Readme)
|
||||
data, err := options.Readme(opts.Readme)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetRepoInitFile[%s]: %w", opts.Readme, err)
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
|
|||
var buf bytes.Buffer
|
||||
names := strings.Split(opts.Gitignores, ",")
|
||||
for _, name := range names {
|
||||
data, err = options.GetRepoInitFile("gitignore", name)
|
||||
data, err = options.Gitignore(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetRepoInitFile[%s]: %w", name, err)
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
|
|||
|
||||
// LICENSE
|
||||
if len(opts.License) > 0 {
|
||||
data, err = options.GetRepoInitFile("license", opts.License)
|
||||
data, err = options.License(opts.License)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetRepoInitFile[%s]: %w", opts.License, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue