You've already forked go-semantic-release
style(lint): fix lint issues
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// Package analyzer provides different commit analyzer
|
||||
package analyzer
|
||||
|
||||
import (
|
||||
@@ -5,20 +6,23 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
//Analyzer struct
|
||||
type Analyzer struct {
|
||||
CommitFormat string
|
||||
}
|
||||
|
||||
//Rules for commits
|
||||
type Rules struct {
|
||||
Tag string
|
||||
Release string
|
||||
}
|
||||
|
||||
type AnalyzeCommit interface {
|
||||
Analyze(commit gitutil.Commit, tag string) (AnalyzedCommit, bool)
|
||||
GetRules() []Rules
|
||||
type analyzeCommit interface {
|
||||
analyze(commit gitutil.Commit, tag string) (AnalyzedCommit, bool)
|
||||
getRules() []Rules
|
||||
}
|
||||
|
||||
//AnalyzedCommit struct
|
||||
type AnalyzedCommit struct {
|
||||
Commit gitutil.Commit
|
||||
ParsedMessage string
|
||||
@@ -26,6 +30,7 @@ type AnalyzedCommit struct {
|
||||
ParsedBreakingChangeMessage string
|
||||
}
|
||||
|
||||
//New Analyzer struct for given commit format
|
||||
func New(format string) *Analyzer {
|
||||
return &Analyzer{
|
||||
CommitFormat: format,
|
||||
@@ -33,13 +38,14 @@ func New(format string) *Analyzer {
|
||||
|
||||
}
|
||||
|
||||
// Analyze commits and return commits splitted by major,minor,patch
|
||||
func (a *Analyzer) Analyze(commits []gitutil.Commit) map[string][]AnalyzedCommit {
|
||||
|
||||
var commitAnalayzer AnalyzeCommit
|
||||
var commitAnalayzer analyzeCommit
|
||||
switch a.CommitFormat {
|
||||
case "angular":
|
||||
log.Infof("analyze angular format")
|
||||
commitAnalayzer = NewAngular()
|
||||
commitAnalayzer = newAngular()
|
||||
}
|
||||
|
||||
analyzedCommits := make(map[string][]AnalyzedCommit)
|
||||
@@ -48,8 +54,8 @@ func (a *Analyzer) Analyze(commits []gitutil.Commit) map[string][]AnalyzedCommit
|
||||
analyzedCommits["patch"] = make([]AnalyzedCommit, 0)
|
||||
|
||||
for _, commit := range commits {
|
||||
for _, rule := range commitAnalayzer.GetRules() {
|
||||
analyzedCommit, hasBreakingChange := commitAnalayzer.Analyze(commit, rule.Tag)
|
||||
for _, rule := range commitAnalayzer.getRules() {
|
||||
analyzedCommit, hasBreakingChange := commitAnalayzer.analyze(commit, rule.Tag)
|
||||
if hasBreakingChange {
|
||||
analyzedCommits["major"] = append(analyzedCommits["major"], analyzedCommit)
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Package analyzer provides different commit analyzer
|
||||
package analyzer
|
||||
|
||||
import (
|
||||
@@ -7,13 +8,13 @@ import (
|
||||
"github.com/Nightapes/go-semantic-release/internal/gitutil"
|
||||
)
|
||||
|
||||
type Angular struct {
|
||||
type angular struct {
|
||||
rules []Rules
|
||||
regex string
|
||||
}
|
||||
|
||||
func NewAngular() *Angular {
|
||||
return &Angular{
|
||||
func newAngular() *angular {
|
||||
return &angular{
|
||||
regex: `(TAG)(?:\((.*)\))?: (.*)`,
|
||||
rules: []Rules{
|
||||
{
|
||||
@@ -31,11 +32,11 @@ func NewAngular() *Angular {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Angular) GetRules() []Rules {
|
||||
func (a *angular) getRules() []Rules {
|
||||
return a.rules
|
||||
}
|
||||
|
||||
func (a *Angular) Analyze(commit gitutil.Commit, tag string) (AnalyzedCommit, bool) {
|
||||
func (a *angular) analyze(commit gitutil.Commit, tag string) (AnalyzedCommit, bool) {
|
||||
|
||||
analyzed := AnalyzedCommit{
|
||||
Commit: commit,
|
||||
|
||||
Reference in New Issue
Block a user