[fxicfg] Don't consider markdown files as stale
This is to prevent this file from being deleted:
https://fuchsia.googlesource.com/integration/+/master/infra/config/generated/fuchsia/specs/README.md
Bug: IN-1463
Change-Id: Ia556c74e31d2f7467f9e1b7cb477cd49dddc34d7
diff --git a/fxicfg/state/state.go b/fxicfg/state/state.go
index fec085f..4e3ca54 100644
--- a/fxicfg/state/state.go
+++ b/fxicfg/state/state.go
@@ -112,7 +112,9 @@
stale := []string{}
for _, path := range oldPaths {
- if !isCurrent[path] {
+ // We don't want to delete markdown files because they
+ // may be added manually rather than generated.
+ if !isCurrent[path] && filepath.Ext(path) != ".md" {
stale = append(stale, path)
}
}
diff --git a/fxicfg/state/state_test.go b/fxicfg/state/state_test.go
index 0d62c9f..bd6da4f 100644
--- a/fxicfg/state/state_test.go
+++ b/fxicfg/state/state_test.go
@@ -24,7 +24,7 @@
},
{
name: "when existing paths are removed",
- oldPaths: []string{"a", "b", "c"},
+ oldPaths: []string{"a", "b", "c", "d.md"},
newPaths: []string{"a"},
stalePaths: []string{"b", "c"},
},