diff --git a/example.easyp.yaml b/example.easyp.yaml index 9f3a0e7..d501b6a 100644 --- a/example.easyp.yaml +++ b/example.easyp.yaml @@ -18,6 +18,8 @@ breaking: ignore: - some_dir against_git_ref: master + use: + - FILES_CHECK generate: inputs: diff --git a/internal/api/temporaly_helper.go b/internal/api/temporaly_helper.go index b61f059..f7c2847 100644 --- a/internal/api/temporaly_helper.go +++ b/internal/api/temporaly_helper.go @@ -7,6 +7,7 @@ import ( "log/slog" "os" "path/filepath" + "slices" "strings" "github.com/samber/lo" @@ -95,9 +96,12 @@ func buildCore(_ context.Context, log logger.Logger, cfg config.Config, dirWalke linterIgnoreDirs := append(cfg.Lint.Ignore, vendorPath) breakingCheckIgnoreDirs := append(cfg.BreakingCheck.Ignore, vendorPath) + filesCheck := slices.Contains(cfg.BreakingCheck.Use, core.BreakingCheckFilesCheck) + breakingCheckConfig := core.BreakingCheckConfig{ IgnoreDirs: breakingCheckIgnoreDirs, AgainstGitRef: cfg.BreakingCheck.AgainstGitRef, + FilesCheck: filesCheck, } // Convert managed mode configuration diff --git a/internal/config/breaking_check.go b/internal/config/breaking_check.go index 46f8fbd..13bc3fb 100644 --- a/internal/config/breaking_check.go +++ b/internal/config/breaking_check.go @@ -4,5 +4,6 @@ package config type BreakingCheck struct { Ignore []string `json:"ignore,omitempty" yaml:"ignore,omitempty"` // git ref to compare with - AgainstGitRef string `json:"against_git_ref,omitempty" yaml:"against_git_ref,omitempty"` + AgainstGitRef string `json:"against_git_ref,omitempty" yaml:"against_git_ref,omitempty"` + Use []string `json:"use,omitempty" yaml:"use,omitempty"` } diff --git a/internal/core/breaking_check.go b/internal/core/breaking_check.go index ac6242f..3cf49b9 100644 --- a/internal/core/breaking_check.go +++ b/internal/core/breaking_check.go @@ -15,11 +15,17 @@ import ( var ErrRootOutsideProject = fmt.Errorf("breaking check root must be inside the git repository") +const ( + BreakingCheckFilesCheck string = "FILES_CHECK" +) + type BreakingCheckConfig struct { // branch name to compare with AgainstGitRef string // dirs should be ignored IgnoreDirs []string + + FilesCheck bool } func (c *Core) BreakingCheck(ctx context.Context, projectRoot, workingDir, path string) ([]IssueInfo, error) { @@ -68,6 +74,8 @@ func (c *Core) BreakingCheck(ctx context.Context, projectRoot, workingDir, path breakingChecker := &BreakingChecker{ against: againstProtoData, current: currentProtoData, + + filesCheck: c.breakingCheckConfig.FilesCheck, } return breakingChecker.Check() diff --git a/internal/core/breaking_checker.go b/internal/core/breaking_checker.go index 55d68f1..ed620ae 100644 --- a/internal/core/breaking_checker.go +++ b/internal/core/breaking_checker.go @@ -12,6 +12,8 @@ const breakingCheckRuleName = "BREAKING_CHECK" type BreakingChecker struct { against ProtoData current ProtoData + + filesCheck bool } func (b *BreakingChecker) Check() ([]IssueInfo, error) {