From 195b413e999d2d32ce646f568b044e8dfa8e4b75 Mon Sep 17 00:00:00 2001 From: Julien Tant Date: Wed, 1 Aug 2018 09:22:57 +0200 Subject: [PATCH] move default wip prefixes into settings Signed-off-by: Julien Tant --- custom/conf/app.ini.sample | 3 +++ models/pull.go | 10 ++-------- modules/setting/defaults.go | 5 +++-- modules/setting/setting.go | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/custom/conf/app.ini.sample b/custom/conf/app.ini.sample index 97a0eac02c530..ca6ac849013ce 100644 --- a/custom/conf/app.ini.sample +++ b/custom/conf/app.ini.sample @@ -60,6 +60,9 @@ FILE_MAX_SIZE = 3 ; Max number of files per upload. Defaults to 5 MAX_FILES = 5 +[repository.pull-request] +WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP] + [ui] ; Number of repositories that are displayed on one explore page EXPLORE_PAGING_NUM = 20 diff --git a/models/pull.go b/models/pull.go index ac84c93246fc3..5e7d716029c6a 100644 --- a/models/pull.go +++ b/models/pull.go @@ -1195,12 +1195,6 @@ func (pr *PullRequest) checkAndUpdateStatus() { } } -// Enumerate the prefixes that will help determine if a pull request is a Work In Progress -var pullRequestWorkInProgressPrefixes = [...]string{ - "WIP:", - "[WIP]", -} - // IsWorkInProgress determine if the Pull Request is a Work In Progress by its title func (pr *PullRequest) IsWorkInProgress() bool { if err := pr.LoadIssue(); err != nil { @@ -1208,7 +1202,7 @@ func (pr *PullRequest) IsWorkInProgress() bool { return false } - for _, prefix := range pullRequestWorkInProgressPrefixes { + for _, prefix := range setting.Repository.PullRequest.WorkInProgressPrefixes { if strings.HasPrefix(strings.ToUpper(pr.Issue.Title), prefix) { return true } @@ -1224,7 +1218,7 @@ func (pr *PullRequest) GetWorkInProgressPrefix() string { return "" } - for _, prefix := range pullRequestWorkInProgressPrefixes { + for _, prefix := range setting.Repository.PullRequest.WorkInProgressPrefixes { if strings.HasPrefix(strings.ToUpper(pr.Issue.Title), prefix) { return pr.Issue.Title[0:len(prefix)] } diff --git a/modules/setting/defaults.go b/modules/setting/defaults.go index 527a6af3b9b04..7630d10090ed5 100644 --- a/modules/setting/defaults.go +++ b/modules/setting/defaults.go @@ -5,6 +5,7 @@ import ( ) var ( - defaultLangs = strings.Split("en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,uk-UA,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR", ",") - defaultLangNames = strings.Split("English,简体中文,繁體中文(香港),繁體中文(台灣),Deutsch,français,Nederlands,latviešu,русский,Українська,日本語,español,português do Brasil,polski,български,italiano,suomi,Türkçe,čeština,српски,svenska,한국어", ",") + defaultLangs = strings.Split("en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,uk-UA,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR", ",") + defaultLangNames = strings.Split("English,简体中文,繁體中文(香港),繁體中文(台灣),Deutsch,français,Nederlands,latviešu,русский,Українська,日本語,español,português do Brasil,polski,български,italiano,suomi,Türkçe,čeština,српски,svenska,한국어", ",") + defaultPullRequestWorkInProgressPrefixes = strings.Split("WIP:,[WIP]", ",") ) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 1b9919404cfee..78bee7999a58d 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -223,6 +223,11 @@ var ( LocalCopyPath string LocalWikiPath string } `ini:"-"` + + // Pull request settings + PullRequest struct { + WorkInProgressPrefixes []string + } `ini:"repository.pull-request"` }{ AnsiCharset: "", ForcePrivate: false, @@ -266,6 +271,13 @@ var ( LocalCopyPath: "tmp/local-repo", LocalWikiPath: "tmp/local-wiki", }, + + // Pull request settings + PullRequest: struct { + WorkInProgressPrefixes []string + }{ + WorkInProgressPrefixes: defaultPullRequestWorkInProgressPrefixes, + }, } RepoRootPath string ScriptType = "bash" @@ -1024,6 +1036,8 @@ func NewContext() { log.Fatal(4, "Failed to map Repository.Upload settings: %v", err) } else if err = Cfg.Section("repository.local").MapTo(&Repository.Local); err != nil { log.Fatal(4, "Failed to map Repository.Local settings: %v", err) + } else if err = Cfg.Section("repository.pull-request").MapTo(&Repository.PullRequest); err != nil { + log.Fatal(4, "Failed to map Repository.PullRequest settings: %v", err) } if !filepath.IsAbs(Repository.Upload.TempPath) {