Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions internal/git/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")):
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions internal/git/scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,28 @@ 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) {},
changedFiles: []string{"README.md"},
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) {},
Expand Down Expand Up @@ -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 {
Expand Down
Loading