diff options
author | Unknown <joe2010xtmf@163.com> | 2014-06-03 21:51:25 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-06-03 21:51:25 -0400 |
commit | 11f9d738e8a1bce4c35bc5e1c37f5a7d1bcded5c (patch) | |
tree | 408022f7e4ac8e8c25ed3cba5ea98ed4721cf08e | |
parent | 63baf76ab2f4a510b4fb981e81feb5ae533b1639 (diff) | |
download | gitea-11f9d738e8a1bce4c35bc5e1c37f5a7d1bcded5c.tar.gz gitea-11f9d738e8a1bce4c35bc5e1c37f5a7d1bcded5c.zip |
Fix #237
-rw-r--r-- | models/repo.go | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/models/repo.go b/models/repo.go index 5d28174b01..869059fa2e 100644 --- a/models/repo.go +++ b/models/repo.go @@ -489,22 +489,40 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep // .gitignore if repoLang != "" { filePath := "conf/gitignore/" + repoLang - if com.IsFile(filePath) { - if err := com.Copy(filePath, - filepath.Join(tmpDir, fileName["gitign"])); err != nil { + targetPath := path.Join(tmpDir, fileName["gitign"]) + data, err := bin.Asset(filePath) + if err == nil { + if err = ioutil.WriteFile(targetPath, data, os.ModePerm); err != nil { return err } + } else { + // Check custom files. + filePath = path.Join(setting.CustomPath, "conf/gitignore", repoLang) + if com.IsFile(filePath) { + if err := com.Copy(filePath, targetPath); err != nil { + return err + } + } } } // LICENSE if license != "" { filePath := "conf/license/" + license - if com.IsFile(filePath) { - if err := com.Copy(filePath, - filepath.Join(tmpDir, fileName["license"])); err != nil { + targetPath := path.Join(tmpDir, fileName["license"]) + data, err := bin.Asset(filePath) + if err == nil { + if err = ioutil.WriteFile(targetPath, data, os.ModePerm); err != nil { return err } + } else { + // Check custom files. + filePath = path.Join(setting.CustomPath, "conf/license", license) + if com.IsFile(filePath) { + if err := com.Copy(filePath, targetPath); err != nil { + return err + } + } } } |