fix: convert git directory check warning to error #257
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
We sometimes fail to get current commit hash. This is because we improperly pass a file rather than directory to the git command. Here is a representative warning:
2025-04-14 21:31:31,930 - root - WARNING - Exception when getting current commit hash: [Errno 20] Not a directory: '/Users/ezyang/Dev/codemcp/codemcp/agno.py'
Traceback (most recent call last):
File "/Users/ezyang/Dev/codemcp/codemcp/git_query.py", line 279, in get_current_commit_hash
result = await run_command(
^^^^^^^^^^^^^^^^^^
File "/Users/ezyang/Dev/codemcp/codemcp/shell.py", line 73, in run_command
process = await asyncio.create_subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/subprocess.py", line 224, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 1756, in subprocess_exec
transport = await self._make_subprocess_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 211, in makesubprocess_transport
transp = _UnixSubprocessTransport(self, protocol, args, shell,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_subprocess.py", line 36, in init
self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 820, in _start
self._proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/subprocess.py", line 1028, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/subprocess.py", line 1963, in executechild
raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: '/Users/ezyang/Dev/codemcp/codemcp/agno.py'
Convert this warning into a hard error, and add a test which triggers the failure. The test SHOULD fail. Halt when done so I can inspect, before we fix.
codemcp-id: 265-fix-convert-git-directory-check-warning-to-error