diff --git a/src/specify_cli/presets/_resolver.py b/src/specify_cli/presets/_resolver.py index ea1c4e03f9..7219c70200 100644 --- a/src/specify_cli/presets/_resolver.py +++ b/src/specify_cli/presets/_resolver.py @@ -466,7 +466,7 @@ def resolve_with_source( resolved_str = str(resolved) # Determine source attribution - if str(self.overrides_dir) in resolved_str: + if resolved.is_relative_to(self.overrides_dir): return {"path": resolved_str, "source": "project override"} if str(self.presets_dir) in resolved_str and self.presets_dir.exists(): diff --git a/tests/specify_cli/presets/test_resolver.py b/tests/specify_cli/presets/test_resolver.py index d1e416f7a1..bcd02ecabd 100644 --- a/tests/specify_cli/presets/test_resolver.py +++ b/tests/specify_cli/presets/test_resolver.py @@ -468,6 +468,15 @@ def test_resolve_with_source_core(self, project_dir): assert result["source"] == "core" assert "spec-template.md" in result["path"] + def test_resolve_with_source_core_name_starting_with_overrides(self, project_dir): + """A core filename sharing the overrides prefix is still core.""" + core = project_dir / ".specify" / "templates" / "overrides-report.md" + core.write_text("# Core report\n") + + result = PresetResolver(project_dir).resolve_with_source("overrides-report") + + assert result == {"path": str(core), "source": "core"} + def test_resolve_with_source_override(self, project_dir): """Test resolve_with_source for override template.""" overrides_dir = project_dir / ".specify" / "templates" / "overrides"