summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-28 00:06:22 -0700
committerUnknwon <u@gogs.io>2016-08-28 00:06:22 -0700
commitdad5c155202a79514e60e73ac019191218167d35 (patch)
tree0a7e5d52657130a49ba78ac7f872ff26719cbcf4 /models
parent6e171c5225edc7969e979c7a9d736b7b1506b6d4 (diff)
downloadgitea-dad5c155202a79514e60e73ac019191218167d35.tar.gz
gitea-dad5c155202a79514e60e73ac019191218167d35.zip
#2901 allow setting preferred licenses
- Closes #3488
Diffstat (limited to 'models')
-rw-r--r--models/repo.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go
index 1d425fe327..aab35785fc 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -62,6 +62,7 @@ var (
func LoadRepoConfig() {
// Load .gitignore and license files and readme templates.
+ // TODO: should we allow custom files overwrite default ones?
types := []string{"gitignore", "license", "readme"}
typeFiles := make([][]string, 3)
for i, t := range types {
@@ -91,6 +92,20 @@ func LoadRepoConfig() {
sort.Strings(Gitignores)
sort.Strings(Licenses)
sort.Strings(Readmes)
+
+ // Filter out invalid names and promote preferred licenses.
+ sortedLicenses := make([]string, 0, len(Licenses))
+ for _, name := range setting.Repository.PreferredLicenses {
+ if com.IsSliceContainsStr(Licenses, name) {
+ sortedLicenses = append(sortedLicenses, name)
+ }
+ }
+ for _, name := range Licenses {
+ if !com.IsSliceContainsStr(setting.Repository.PreferredLicenses, name) {
+ sortedLicenses = append(sortedLicenses, name)
+ }
+ }
+ Licenses = sortedLicenses
}
func NewRepoContext() {