mirror of
https://github.com/theonedev/onedev.git
synced 2025-12-11 04:40:59 -06:00
feat: Able to use conventional commit types configured in branch protection rule for PR title generation (OD-2540)
This commit is contained in:
parent
1e477e2347
commit
9f3ad0bc11
@ -1406,8 +1406,13 @@ public class PullRequest extends ProjectBelonging
|
||||
wip = true;
|
||||
title = title.substring(4);
|
||||
}
|
||||
var commitTypes = CONVENTIONAL_COMMIT_TYPES;
|
||||
var branchProtection = getProject().getBranchProtection(getTargetBranch(), getSubmitter());
|
||||
if (branchProtection.isEnforceConventionalCommits() && !branchProtection.getCommitTypes().isEmpty()) {
|
||||
commitTypes = branchProtection.getCommitTypes();
|
||||
}
|
||||
boolean found = false;
|
||||
for (var commitType: CONVENTIONAL_COMMIT_TYPES) {
|
||||
for (var commitType: commitTypes) {
|
||||
if (title.startsWith(commitType + "-") || title.startsWith(commitType + "_") || title.startsWith(commitType + "/")) {
|
||||
title = commitType + ": " + StringUtils.capitalize(title.substring(commitType.length() + 1).replace('-', ' ').replace('_', ' ').replace('/', ' '));
|
||||
found = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user