#2901 allow setting preferred licenses

- Closes #3488
pull/197/head
Unknwon 8 years ago
parent 6e171c5225
commit dad5c15520
  1. 2
      README.md
  2. 3
      conf/app.ini
  3. 2
      gogs.go
  4. 15
      models/repo.go
  5. 4
      modules/bindata/bindata.go
  6. 1
      modules/setting/setting.go
  7. 2
      templates/.VERSION

@ -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) ![](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 | | Web | UI | Preview |
|:-------------:|:-------:|:-------:| |:-------------:|:-------:|:-------:|

@ -19,6 +19,9 @@ FORCE_PRIVATE = false
MAX_CREATION_LIMIT = -1 MAX_CREATION_LIMIT = -1
; Patch test queue length, make it as large as possible ; Patch test queue length, make it as large as possible
PULL_REQUEST_QUEUE_LENGTH = 10000 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] [repository.editor]
; List of file extensions that should have line wraps in the CodeMirror 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" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.9.89.0827" const APP_VER = "0.9.90.0828"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

@ -62,6 +62,7 @@ var (
func LoadRepoConfig() { func LoadRepoConfig() {
// Load .gitignore and license files and readme templates. // Load .gitignore and license files and readme templates.
// TODO: should we allow custom files overwrite default ones?
types := []string{"gitignore", "license", "readme"} types := []string{"gitignore", "license", "readme"}
typeFiles := make([][]string, 3) typeFiles := make([][]string, 3)
for i, t := range types { for i, t := range types {
@ -91,6 +92,20 @@ func LoadRepoConfig() {
sort.Strings(Gitignores) sort.Strings(Gitignores)
sort.Strings(Licenses) sort.Strings(Licenses)
sort.Strings(Readmes) 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() { func NewRepoContext() {

File diff suppressed because one or more lines are too long

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

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