summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-12-22 21:05:38 -0500
committerBen Sima <ben@bensima.com>2025-12-22 21:05:38 -0500
commit9b4887e43ca9cad55f5185060d0479a5d0ca27d9 (patch)
treea41bde01053d4215f7da80e5d1d0fe73649210c5
parent3f8d69dfa6d680e328cbc218cbb20327e506722b (diff)
Omni/Bild: add file filtering to prevent namespace parsing errorsHEADlive
- Add isLikelySourceFile filter to exclude dotfiles and config files - Apply filter before namespaceFromPathOrDie to prevent crashes - Removes need to add every config file type to namespace system - Fixes CI failures from .dir-locals.el and similar files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
-rw-r--r--Omni/Bild.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/Omni/Bild.hs b/Omni/Bild.hs
index fcf959f..39ac01f 100644
--- a/Omni/Bild.hs
+++ b/Omni/Bild.hs
@@ -225,6 +225,7 @@ move args = do
|> filterM Dir.doesFileExist
+> filterGitIgnored
/> filter (\x -> isGitHook x |> don't)
+ /> filter isLikelySourceFile
+> traverse Dir.makeAbsolute
+> traverse (namespaceFromPathOrDie root)
let (namespaces, skippedNamespaces) = partition isBuildableNs allNamespaces
@@ -326,6 +327,40 @@ isGitHook :: FilePath -> Bool
isGitHook path =
"Omni/Ide/hooks" `List.isInfixOf` path
+-- | Filter out files that are clearly not source files to avoid namespace parsing errors
+isLikelySourceFile :: FilePath -> Bool
+isLikelySourceFile path =
+ not (isDotfile path || isConfigFile path)
+ where
+ isDotfile p =
+ let filename = List.reverse (takeWhile (/= '/') (List.reverse p))
+ in case filename of
+ ('.' : _) -> True
+ _ -> False
+ isConfigFile p =
+ any
+ (`List.isSuffixOf` p)
+ [ ".json",
+ ".yaml",
+ ".yml",
+ ".toml",
+ ".ini",
+ ".cfg",
+ ".conf",
+ ".lock",
+ ".log",
+ ".tmp",
+ ".bak",
+ ".orig",
+ "Makefile",
+ "makefile",
+ "Dockerfile",
+ "LICENSE",
+ "README",
+ ".gitignore",
+ ".gitattributes"
+ ]
+
test_isGitHook :: Test.Tree
test_isGitHook =
Test.group