diff options
author | Jason Song <i@wolfogre.com> | 2023-03-08 17:31:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-08 17:31:27 +0800 |
commit | 090e75392385041b3abb30d02564962a3ff687f6 (patch) | |
tree | bd21cf189765a8486d5b4fcb9c0aa68bda4eb46e /modules/repository | |
parent | a12f5757372f751d25f9e5ca1f168f6920ded894 (diff) | |
download | gitea-090e75392385041b3abb30d02564962a3ff687f6.tar.gz gitea-090e75392385041b3abb30d02564962a3ff687f6.zip |
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.
Diffstat (limited to 'modules/repository')
-rw-r--r-- | modules/repository/init.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/repository/init.go b/modules/repository/init.go index 49c8d2a904..f9a33cd4f6 100644 --- a/modules/repository/init.go +++ b/modules/repository/init.go @@ -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) } |