fix: clean up tryReadRuleFile and add missing blank line

- Add blank line between matchProjectRuleEntry and allowedRuleExts (Issue 1)
- Remove dead code '|| repoDir == ' in tryReadRuleFile (Issue 2)
- Remove unnecessary warning when repoDir is empty but path is absolute (Issue 3)
This commit is contained in:
zephyrq-z 2026-06-27 10:51:18 +08:00
parent c44265d63e
commit eaa8e997f8

View file

@ -441,6 +441,7 @@ func matchProjectRuleEntry(pr *ProjectRule, path string) *ProjectRuleEntry {
}
return nil
}
// allowedRuleExts is the set of file extensions permitted for rule file references.
var allowedRuleExts = map[string]bool{".md": true, ".txt": true, ".markdown": true}
@ -486,9 +487,8 @@ func tryReadRuleFile(rule string, repoDir string) *string {
fmt.Fprintf(os.Stderr, "[ocr] WARNING: cannot resolve relative rule path %q without a repo dir\n", rule)
return nil
}
fmt.Fprintf(os.Stderr, "[ocr] WARNING: repoDir is empty, treating rule as absolute path: %s\n", rule)
}
if filepath.IsAbs(rule) || repoDir == "" {
if filepath.IsAbs(rule) {
content, err := readRuleFileSafe(rule)
if err == nil {
return &content