Skip to content

Commit 88077a7

Browse files
committed
feat: check for any scope feature
1 parent d61dc8f commit 88077a7

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ tasks:
8383
- go run . hook activate --global
8484
vars:
8585
PWD:
86-
sh: echo "$(pwd)"
86+
sh: echo "$(pwd)"

interface_cli/actions/validation/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ func Validate(commit conventionalcommits.ConventionalCommit, conf settings.Confi
3131
}
3232
}
3333

34+
if conf.Validation.Rules.Header.Scope.AnyMustBePresent {
35+
if commit.Scope == "" {
36+
return valerrors.NewErrorCommitScopeMustBeDefined(commit)
37+
}
38+
}
39+
3440
if commit.Scope != "" {
3541
if conf.Validation.Rules.Header.Scope.Lowercase {
3642
if !settings.RegexScope.MatchString(string(commit.Scope)) {

settings/autogit.example.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ validation:
9494
- "merge" # Commits to merge branches. Usually we use lowcase ones to update dev branch with master commits
9595
scope:
9696
# feat(scope): smth. Forces to write scope of a commit. Participes in changelog generation
97+
any_must_be_present: false
9798
enforced_for_commit_types: []
9899
# add any commit type for which u wish to enforce scope being present
99100
# or set enforced_for_commit_types: [], for disabling it

settings/validations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type ValidationScheme struct {
3939
Allowlists TypeAllowLists `yaml:"allowlists"`
4040
} `yaml:"type"`
4141
Scope struct {
42+
AnyMustBePresent bool `yaml:"any_must_be_present"`
4243
EnforcedForTypes []conventionalcommitstype.Type `yaml:"enforced_for_commit_types"`
4344
Lowercase bool `yaml:"lowercase"`
4445
Allowlist []conventionalcommitstype.Scope `yaml:"allowlist"`

0 commit comments

Comments
 (0)