#2901 allow setting preferred licenses

- Closes #3488
release/v0.9
Unknwon 8 years ago
parent 6e171c5225
commit dad5c15520

@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
##### Current tip version: 0.9.89 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
##### Current tip version: 0.9.90 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
| Web | UI | Preview |
|:-------------:|:-------:|:-------:|

@ -19,6 +19,9 @@ FORCE_PRIVATE = false
MAX_CREATION_LIMIT = -1
; Patch test queue length, make it as large as possible
PULL_REQUEST_QUEUE_LENGTH = 10000
; Preferred Licenses to place at the top of the List
; Name must match file name in conf/license or custom/conf/license
PREFERRED_LICENSES = Apache License 2.0,MIT License
[repository.editor]
; List of file extensions that should have line wraps in the CodeMirror editor

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.9.89.0827"
const APP_VER = "0.9.90.0828"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())

@ -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() {

File diff suppressed because one or more lines are too long

@ -114,6 +114,7 @@ var (
ForcePrivate bool
MaxCreationLimit int
PullRequestQueueLength int
PreferredLicenses []string
// Repository editor settings
Editor struct {

@ -1 +1 @@
0.9.89.0827
0.9.90.0828
Loading…
Cancel
Save