@@ -101,6 +101,81 @@ def test_case_mismatch_on_windows_git(tmp_path: Path) -> None:
101
101
assert res is not None
102
102
103
103
104
+ @pytest .mark .skipif (sys .platform != "win32" , reason = "this bug is only valid on windows" )
105
+ def test_case_mismatch_nested_dir_windows_git (tmp_path : Path ) -> None :
106
+ """Test case where we have a nested directory with different casing"""
107
+ # Create git repo in my_repo
108
+ repo_path = tmp_path / "my_repo"
109
+ repo_path .mkdir ()
110
+ run ("git init" , repo_path )
111
+
112
+ # Create a nested directory with specific casing
113
+ nested_dir = repo_path / "CasedDir"
114
+ nested_dir .mkdir ()
115
+
116
+ # Create a pyproject.toml in the nested directory
117
+ (nested_dir / "pyproject.toml" ).write_text ("""
118
+ [build-system]
119
+ requires = ["setuptools>=64", "setuptools-scm"]
120
+ build-backend = "setuptools.build_meta"
121
+
122
+ [project]
123
+ name = "test-project"
124
+ dynamic = ["version"]
125
+
126
+ [tool.setuptools_scm]
127
+ """ )
128
+
129
+ # Add and commit the file
130
+ run ("git add ." , repo_path )
131
+ run ("git commit -m 'Initial commit'" , repo_path )
132
+
133
+ # Now try to parse from the nested directory with lowercase path
134
+ # This simulates: cd my_repo/caseddir (lowercase) when actual dir is CasedDir
135
+ lowercase_nested_path = str (nested_dir ).replace ("CasedDir" , "caseddir" )
136
+
137
+ # This should trigger the assertion error in _git_toplevel
138
+ try :
139
+ res = parse (lowercase_nested_path , Configuration ())
140
+ # If we get here without assertion error, the bug is already fixed or not triggered
141
+ print (f"Parse succeeded with result: { res } " )
142
+ except AssertionError as e :
143
+ print (f"AssertionError caught as expected: { e } " )
144
+ # Re-raise so the test fails, showing we reproduced the bug
145
+ raise
146
+
147
+
148
+ def test_case_mismatch_force_assertion_failure (tmp_path : Path ) -> None :
149
+ """Force the assertion failure by directly calling _git_toplevel with mismatched paths"""
150
+ from setuptools_scm ._file_finders .git import _git_toplevel
151
+
152
+ # Create git repo structure
153
+ repo_path = tmp_path / "my_repo"
154
+ repo_path .mkdir ()
155
+ run ("git init" , repo_path )
156
+
157
+ # Create nested directory
158
+ nested_dir = repo_path / "CasedDir"
159
+ nested_dir .mkdir ()
160
+
161
+ # Add and commit something to make it a valid repo
162
+ (nested_dir / "test.txt" ).write_text ("test" )
163
+ run ("git add ." , repo_path )
164
+ run ("git commit -m 'Initial commit'" , repo_path )
165
+
166
+ # Now call _git_toplevel with a path that has different casing
167
+ # This should cause the assertion to fail
168
+ lowercase_nested_path = str (nested_dir ).replace ("CasedDir" , "caseddir" )
169
+
170
+ try :
171
+ result = _git_toplevel (lowercase_nested_path )
172
+ print (f"_git_toplevel returned: { result } " )
173
+ # If no assertion error, either the bug is fixed or we didn't trigger it properly
174
+ except AssertionError as e :
175
+ print (f"AssertionError as expected: { e } " )
176
+ raise # Let the test fail to show we reproduced the issue
177
+
178
+
104
179
def test_entrypoints_load () -> None :
105
180
d = distribution ("setuptools-scm" )
106
181
0 commit comments