|
|
@ -489,24 +489,42 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep |
|
|
|
// .gitignore
|
|
|
|
// .gitignore
|
|
|
|
if repoLang != "" { |
|
|
|
if repoLang != "" { |
|
|
|
filePath := "conf/gitignore/" + repoLang |
|
|
|
filePath := "conf/gitignore/" + repoLang |
|
|
|
|
|
|
|
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 com.IsFile(filePath) { |
|
|
|
if err := com.Copy(filePath, |
|
|
|
if err := com.Copy(filePath, targetPath); err != nil { |
|
|
|
filepath.Join(tmpDir, fileName["gitign"])); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// LICENSE
|
|
|
|
// LICENSE
|
|
|
|
if license != "" { |
|
|
|
if license != "" { |
|
|
|
filePath := "conf/license/" + license |
|
|
|
filePath := "conf/license/" + license |
|
|
|
|
|
|
|
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 com.IsFile(filePath) { |
|
|
|
if err := com.Copy(filePath, |
|
|
|
if err := com.Copy(filePath, targetPath); err != nil { |
|
|
|
filepath.Join(tmpDir, fileName["license"])); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(fileName) == 0 { |
|
|
|
if len(fileName) == 0 { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|