parseMergePullRequestConfig handles merge-pull-request configuration.
(outputMap map[string]any)
| 16 | |
| 17 | // parseMergePullRequestConfig handles merge-pull-request configuration. |
| 18 | func (c *Compiler) parseMergePullRequestConfig(outputMap map[string]any) *MergePullRequestConfig { |
| 19 | configData, exists := outputMap["merge-pull-request"] |
| 20 | if !exists { |
| 21 | return nil |
| 22 | } |
| 23 | |
| 24 | mergePullRequestLog.Print("Parsing merge-pull-request config") |
| 25 | cfg := &MergePullRequestConfig{} |
| 26 | if configMap, ok := configData.(map[string]any); ok { |
| 27 | cfg.RequiredLabels = ParseStringArrayFromConfig(configMap, "required-labels", mergePullRequestLog) |
| 28 | if len(cfg.RequiredLabels) == 0 { |
| 29 | // Deprecated: allowed-labels is migrated to required-labels by the codemod |
| 30 | cfg.RequiredLabels = ParseStringArrayFromConfig(configMap, "allowed-labels", mergePullRequestLog) |
| 31 | } |
| 32 | targetConfig, _ := ParseTargetConfig(configMap) |
| 33 | cfg.SafeOutputTargetConfig = targetConfig |
| 34 | cfg.AllowedBranches = ParseStringArrayFromConfig(configMap, "allowed-branches", mergePullRequestLog) |
| 35 | cfg.RequiredTitlePrefix = extractStringFromMap(configMap, "required-title-prefix", mergePullRequestLog) |
| 36 | c.parseBaseSafeOutputConfig(configMap, &cfg.BaseSafeOutputConfig, 1) |
| 37 | mergePullRequestLog.Printf("Parsed merge-pull-request config: requiredLabels=%v, allowedBranches=%v, requiredTitlePrefix=%q", cfg.RequiredLabels, cfg.AllowedBranches, cfg.RequiredTitlePrefix) |
| 38 | return cfg |
| 39 | } |
| 40 | |
| 41 | // merge-pull-request: null enables defaults |
| 42 | cfg.Max = defaultIntStr(1) |
| 43 | return cfg |
| 44 | } |