diff options
author | Thomas Boerger <thomas@webhippie.de> | 2016-12-22 19:12:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 19:12:23 +0100 |
commit | b33078fa33441c33c5d018b1b9a248c646549842 (patch) | |
tree | 0f890f88987764c1409c6c9d90edd8e727f3219e /models | |
parent | c21e2c4151b5bc13e54de902f59e7b4c46b47540 (diff) | |
download | gitea-b33078fa33441c33c5d018b1b9a248c646549842.tar.gz gitea-b33078fa33441c33c5d018b1b9a248c646549842.zip |
Bindata is optional and over-writable on restart (#354)
* Moved conf assets into options folder
* Dropped old bindata
* Started to integrate options bindata and accessors
* Do not enforce a builtin app.ini
* Replaced bindata calls with options
* Dropped bindata task from makefile, it's the generate task now
* Always embedd app.ini to provide sane config defaults
* Use sane defaults for the configuration
* Defined default value for SSH_KEYGEN_PATH
* Dropped "NEVER EVER MODIFY THIS FILE" header from app.ini
* Fixed new paths in latest test additions
* Drop bindata with make clean task
* Set more proper default values
Diffstat (limited to 'models')
-rw-r--r-- | models/repo.go | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/models/repo.go b/models/repo.go index 6bde92449f..42e9256d22 100644 --- a/models/repo.go +++ b/models/repo.go @@ -20,9 +20,9 @@ import ( "time" "code.gitea.io/git" - "code.gitea.io/gitea/modules/bindata" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markdown" + "code.gitea.io/gitea/modules/options" "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/sync" @@ -80,11 +80,11 @@ func LoadRepoConfig() { types := []string{"gitignore", "license", "readme", "label"} typeFiles := make([][]string, 4) for i, t := range types { - files, err := bindata.AssetDir("conf/" + t) + files, err := options.Dir(t) if err != nil { log.Fatal(4, "Fail to get %s files: %v", t, err) } - customPath := path.Join(setting.CustomPath, "conf", t) + customPath := path.Join(setting.CustomPath, "options", t) if com.IsDir(customPath) { customFiles, err := com.StatDir(customPath) if err != nil { @@ -827,14 +827,25 @@ type CreateRepoOptions struct { } func getRepoInitFile(tp, name string) ([]byte, error) { - relPath := path.Join("conf", tp, strings.TrimLeft(name, "./")) + cleanedName := strings.TrimLeft(name, "./") + relPath := path.Join("options", tp, cleanedName) // Use custom file when available. customPath := path.Join(setting.CustomPath, relPath) if com.IsFile(customPath) { return ioutil.ReadFile(customPath) } - return bindata.Asset(relPath) + + switch tp { + case "readme": + return options.Readme(cleanedName) + case "gitignore": + return options.Gitignore(cleanedName) + case "license": + return options.License(cleanedName) + default: + return []byte{}, fmt.Errorf("Invalid init file type") + } } func prepareRepoCommit(repo *Repository, tmpDir, repoPath string, opts CreateRepoOptions) error { |