Skip to content

Commit

Permalink
move default wip prefixes into settings
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Tant <julien@craftyx.fr>
  • Loading branch information
JulienTant committed Aug 1, 2018
1 parent 864f795 commit 195b413
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
3 changes: 3 additions & 0 deletions custom/conf/app.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -1195,20 +1195,14 @@ 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 {
log.Error(4, "LoadIssue: %v", err)
return false
}

for _, prefix := range pullRequestWorkInProgressPrefixes {
for _, prefix := range setting.Repository.PullRequest.WorkInProgressPrefixes {
if strings.HasPrefix(strings.ToUpper(pr.Issue.Title), prefix) {
return true
}
Expand All @@ -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)]
}
Expand Down
5 changes: 3 additions & 2 deletions modules/setting/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]", ",")
)
14 changes: 14 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ var (
LocalCopyPath string
LocalWikiPath string
} `ini:"-"`

// Pull request settings
PullRequest struct {
WorkInProgressPrefixes []string
} `ini:"repository.pull-request"`
}{
AnsiCharset: "",
ForcePrivate: false,
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 195b413

Please sign in to comment.