Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

fix(xccode): detect lower-case license.txt / License.md (#2201) (#2202)

xerj-org951805605ca2
diff --git a/engine/crates/xerj-common/src/xccode/licence.rs b/engine/crates/xerj-common/src/xccode/licence.rs
index 64312bcb3..fb4874569 100644
--- a/engine/crates/xerj-common/src/xccode/licence.rs
+++ b/engine/crates/xerj-common/src/xccode/licence.rs
@@ -129,8 +129,12 @@ pub fn detect_licence(repo_dir: &std::path::Path) -> String {
.flatten()
.filter(|e| e.path().is_file())
.map(|e| e.file_name().to_string_lossy().to_string())
+ // Case-insensitive: plenty of projects ship `license.txt`,
+ // `License.md` or `copying` (jfreechart, ta4j; issue #2201), and a
+ // missed file records NONE-FOUND, which is treated as restricted.
.filter(|n| {
- n.starts_with("LICENSE") || n.starts_with("LICENCE") || n.starts_with("COPYING")
+ let u = n.to_uppercase();
+ u.starts_with("LICENSE") || u.starts_with("LICENCE") || u.starts_with("COPYING")
})
.collect();
names.sort();
@@ -492,6 +496,30 @@ mod tests {
assert_eq!(detect_licence(&empty), "NONE-FOUND");
}
+ #[test]
+ fn detect_licence_file_name_is_case_insensitive() {
+ // Issue #2201: jfreechart ships `license.txt` (LGPL-2.1) and was
+ // recorded NONE-FOUND.
+ let holder = tempfile::tempdir().unwrap();
+ let repo = holder.path().join("jfreechart");
+ std::fs::create_dir_all(&repo).unwrap();
+ std::fs::write(
+ repo.join("license.txt"),
+ "GNU LESSER GENERAL PUBLIC LICENSE\nVersion 2.1, February 1999",
+ )
+ .unwrap();
+ assert_eq!(detect_licence(&repo), "LGPL");
+
+ let mixed = holder.path().join("mixed");
+ std::fs::create_dir_all(&mixed).unwrap();
+ std::fs::write(
+ mixed.join("License.md"),
+ "MIT License\n\nPermission is hereby granted, free of charge",
+ )
+ .unwrap();
+ assert_eq!(detect_licence(&mixed), "MIT");
+ }
+
#[test]
fn detect_reads_title_first_then_body() {
let holder = tempfile::tempdir().unwrap();