diff --git a/internal/git/scope.go b/internal/git/scope.go index 117e6bc..5cd2b13 100644 --- a/internal/git/scope.go +++ b/internal/git/scope.go @@ -37,7 +37,7 @@ func ResolveScope(root string, changedFiles []string, envFile string) Scope { continue } switch { - case f == "base.yml", f == envFile, strings.HasPrefix(f, "labels/"): + case f == "base.yml", f == envFile, strings.HasPrefix(f, "labels/") && !strings.HasSuffix(f, ".md"): scope.IncludeGlobal = true case strings.HasPrefix(f, "teams/") && (strings.HasSuffix(f, ".yml") || strings.HasSuffix(f, ".yaml")): @@ -65,8 +65,12 @@ func ResolveScope(root string, changedFiles []string, envFile string) Scope { return scope } -// isFleetResource returns true for files under the fleet-managed resource dirs. +// isFleetResource returns true for files under the fleet-managed resource dirs, +// excluding markdown files which are documentation, not fleet config. func isFleetResource(f string) bool { + if strings.HasSuffix(f, ".md") { + return false + } for _, prefix := range fleetResourcePrefixes { if strings.HasPrefix(f, prefix) { return true diff --git a/internal/git/scope_test.go b/internal/git/scope_test.go index f6393ec..a0dd695 100644 --- a/internal/git/scope_test.go +++ b/internal/git/scope_test.go @@ -67,6 +67,13 @@ func TestResolveScope(t *testing.T) { wantGlobal: true, wantTeamCount: 0, }, + { + name: "labels/README.md does not set IncludeGlobal", + setup: func(t *testing.T, root string) {}, + changedFiles: []string{"labels/README.md"}, + wantGlobal: false, + wantTeamCount: 0, + }, { name: "non-fleet file ignored", setup: func(t *testing.T, root string) {}, @@ -74,6 +81,14 @@ func TestResolveScope(t *testing.T) { wantGlobal: false, wantTeamCount: 0, }, + { + name: "README under resource dir ignored", + setup: func(t *testing.T, root string) {}, + changedFiles: []string{"policies/README.md", "scripts/README.md", "queries/README.md"}, + wantGlobal: false, + wantTeamCount: 0, + wantChanged: nil, + }, { name: "path traversal skipped", setup: func(t *testing.T, root string) {}, @@ -164,6 +179,11 @@ func TestIsFleetResource(t *testing.T) { {"README.md", false}, {"base.yml", false}, {"labels/managed.yml", false}, + {"policies/README.md", false}, + {"scripts/README.md", false}, + {"queries/README.md", false}, + {"software/README.md", false}, + {"profiles/README.md", false}, } for _, tt := range tests {