mirror of
https://github.com/lukaszraczylo/semver-generator.git
synced 2026-07-05 03:54:46 +00:00
Add support for the blacklisting
This commit is contained in:
@@ -33,6 +33,7 @@ Project created overnight, to prove that management of semantic versioning is NO
|
|||||||
### Important changes
|
### Important changes
|
||||||
|
|
||||||
* From version `1.4.2+` as pointed out in [issue #12](https://github.com/lukaszraczylo/semver-generator/issues/12) commits from merge will not be included in the calculations and commits themselves will bump the version on first match ( starting checks from `patch` upwards ).
|
* From version `1.4.2+` as pointed out in [issue #12](https://github.com/lukaszraczylo/semver-generator/issues/12) commits from merge will not be included in the calculations and commits themselves will bump the version on first match ( starting checks from `patch` upwards ).
|
||||||
|
* Added support for blacklisting terms to ignore specific commits, branch names, and merge messages from version calculations.
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
@@ -172,6 +173,11 @@ force:
|
|||||||
minor: 0
|
minor: 0
|
||||||
patch: 1
|
patch: 1
|
||||||
commit: 69fbe2df696f40281b9104ff073d26186cde1024
|
commit: 69fbe2df696f40281b9104ff073d26186cde1024
|
||||||
|
blacklist:
|
||||||
|
- "Merge branch"
|
||||||
|
- "Merge pull request"
|
||||||
|
- "feature/"
|
||||||
|
- "feature:"
|
||||||
wording:
|
wording:
|
||||||
patch:
|
patch:
|
||||||
- update
|
- update
|
||||||
@@ -190,10 +196,11 @@ wording:
|
|||||||
* `version`: is not respected at the moment, introduced for potential backwards compatibility in future
|
* `version`: is not respected at the moment, introduced for potential backwards compatibility in future
|
||||||
* `force`: sets the "starting" version, you don't need to specify this section as the default is always `0`
|
* `force`: sets the "starting" version, you don't need to specify this section as the default is always `0`
|
||||||
* `force.commit`: allows you to set commit hash from which the calculations should start
|
* `force.commit`: allows you to set commit hash from which the calculations should start
|
||||||
|
* `blacklist`: terms to ignore when processing commits. Any commit containing these terms will be skipped in version calculations. Useful for ignoring merge commits, feature branch names, and other unwanted triggers.
|
||||||
* `wording`: words the program should look for in the git commits to increment (patch|minor|major)
|
* `wording`: words the program should look for in the git commits to increment (patch|minor|major)
|
||||||
|
|
||||||
### Good to know
|
### Good to know
|
||||||
|
|
||||||
* Word matching uses fuzzy search AND is case INSENSITIVE
|
* Word matching uses fuzzy search AND is case INSENSITIVE
|
||||||
* I do not recommend using common words ( like "the" from the example configuration )
|
* I do not recommend using common words ( like "the" from the example configuration )
|
||||||
* You can specify env variable `LOG_LEVEL=debug` to see what exactly happens during the calculations
|
* You can specify env variable `LOG_LEVEL=debug` to see what exactly happens during the calculations
|
||||||
|
|||||||
+13
-6
@@ -81,6 +81,7 @@ type Setup struct {
|
|||||||
Semver SemVer
|
Semver SemVer
|
||||||
Generate bool
|
Generate bool
|
||||||
UseLocal bool
|
UseLocal bool
|
||||||
|
Blacklist []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommitDetails struct {
|
type CommitDetails struct {
|
||||||
@@ -96,12 +97,17 @@ type TagDetails struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkMatches(content []string, targets []string) bool {
|
func checkMatches(content []string, targets []string) bool {
|
||||||
if fuzzy.MatchNormalizedFold(strings.Join(content, " "), "Merge branch") {
|
contentStr := strings.Join(content, " ")
|
||||||
logger.Debug(&libpack_logger.LogMessage{
|
|
||||||
Message: "Merge detected, ignoring commits within",
|
// Check against blacklist terms first
|
||||||
Pairs: map[string]interface{}{"content": strings.Join(content, " ")},
|
for _, blacklistTerm := range repo.Blacklist {
|
||||||
})
|
if fuzzy.MatchNormalizedFold(contentStr, blacklistTerm) {
|
||||||
return false
|
logger.Debug(&libpack_logger.LogMessage{
|
||||||
|
Message: "Blacklisted term detected, ignoring commit",
|
||||||
|
Pairs: map[string]interface{}{"content": contentStr, "blacklist_term": blacklistTerm},
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for _, tgt := range targets {
|
for _, tgt := range targets {
|
||||||
r := fuzzy.FindNormalizedFold(tgt, content)
|
r := fuzzy.FindNormalizedFold(tgt, content)
|
||||||
@@ -354,6 +360,7 @@ func (s *Setup) ReadConfig(file string) error {
|
|||||||
}
|
}
|
||||||
viper.UnmarshalKey("wording", &s.Wording)
|
viper.UnmarshalKey("wording", &s.Wording)
|
||||||
viper.UnmarshalKey("force", &s.Force)
|
viper.UnmarshalKey("force", &s.Force)
|
||||||
|
viper.UnmarshalKey("blacklist", &s.Blacklist)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ force:
|
|||||||
major: 1
|
major: 1
|
||||||
existing: true
|
existing: true
|
||||||
strict: false
|
strict: false
|
||||||
|
blacklist:
|
||||||
|
- "Merge branch"
|
||||||
|
- "Merge pull request"
|
||||||
|
- "feature/"
|
||||||
|
- "feature:"
|
||||||
wording:
|
wording:
|
||||||
patch:
|
patch:
|
||||||
- update
|
- update
|
||||||
|
|||||||
Reference in New Issue
Block a user