1
0
Fork 0
forked from forgejo/forgejo

Move createrepository from module to service layer (#26927)

Repository creation depends on many models, so moving it to service
layer is better.
This commit is contained in:
Lunny Xiao 2023-09-06 20:08:51 +08:00 committed by GitHub
parent b3d88ada01
commit b9df9fa2e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 510 additions and 482 deletions

View file

@ -13,14 +13,14 @@ import (
"code.gitea.io/gitea/modules/options"
)
type licenseValues struct {
type LicenseValues struct {
Owner string
Email string
Repo string
Year string
}
func getLicense(name string, values *licenseValues) ([]byte, error) {
func GetLicense(name string, values *LicenseValues) ([]byte, error) {
data, err := options.License(name)
if err != nil {
return nil, fmt.Errorf("GetRepoInitFile[%s]: %w", name, err)
@ -28,7 +28,7 @@ func getLicense(name string, values *licenseValues) ([]byte, error) {
return fillLicensePlaceholder(name, values, data), nil
}
func fillLicensePlaceholder(name string, values *licenseValues, origin []byte) []byte {
func fillLicensePlaceholder(name string, values *LicenseValues, origin []byte) []byte {
placeholder := getLicensePlaceholder(name)
scanner := bufio.NewScanner(bytes.NewReader(origin))