aboutsummaryrefslogtreecommitdiff
path: root/internal/db/repo.go
diff options
context:
space:
mode:
authorMichael Li <alimy@gility.net>2022-03-17 14:05:09 +0800
committerGitHub <noreply@github.com>2022-03-17 14:05:09 +0800
commit32c454ba5faea9dc4236c12e28e0b65f01117cc1 (patch)
tree1eea30a83f78b311983924ba3bab00884633f508 /internal/db/repo.go
parent39f64a1371cdb01e02aeeb04839d2689052ae1d3 (diff)
assets: convert usage of go-bindata to Go embed (#6851)
Co-authored-by: Joe Chen <jc@unknwon.io>
Diffstat (limited to 'internal/db/repo.go')
-rw-r--r--internal/db/repo.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/internal/db/repo.go b/internal/db/repo.go
index 083989a9..d6235282 100644
--- a/internal/db/repo.go
+++ b/internal/db/repo.go
@@ -29,6 +29,7 @@ import (
"github.com/gogs/git-module"
api "github.com/gogs/go-gogs-client"
+ embedConf "gogs.io/gogs/conf"
"gogs.io/gogs/internal/avatar"
"gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/db/errors"
@@ -57,10 +58,11 @@ func LoadRepoConfig() {
types := []string{"gitignore", "license", "readme", "label"}
typeFiles := make([][]string, 4)
for i, t := range types {
- files, err := conf.AssetDir("conf/" + t)
+ files, err := embedConf.FileNames(t)
if err != nil {
- log.Fatal("Failed to get %s files: %v", t, err)
+ log.Fatal("Failed to get %q files: %v", t, err)
}
+
customPath := filepath.Join(conf.CustomDir(), "conf", t)
if com.IsDir(customPath) {
customFiles, err := com.StatDir(customPath)
@@ -940,14 +942,14 @@ type CreateRepoOptions struct {
}
func getRepoInitFile(tp, name string) ([]byte, error) {
- relPath := path.Join("conf", tp, strings.TrimLeft(path.Clean("/"+name), "/"))
+ relPath := path.Join(tp, strings.TrimLeft(path.Clean("/"+name), "/"))
// Use custom file when available.
- customPath := filepath.Join(conf.CustomDir(), relPath)
+ customPath := filepath.Join(conf.CustomDir(), "conf", relPath)
if osutil.IsFile(customPath) {
return ioutil.ReadFile(customPath)
}
- return conf.Asset(relPath)
+ return embedConf.Files.ReadFile(relPath)
}
func prepareRepoCommit(repo *Repository, tmpDir, repoPath string, opts CreateRepoOptions) error {