-
Notifications
You must be signed in to change notification settings - Fork 133
fix: convert git directory error to hard error and add test #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ezyang
wants to merge
3
commits into
gh/ezyang/197/base
Choose a base branch
from
gh/ezyang/197/head
base: gh/ezyang/197/base
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ezyang
added a commit
that referenced
this pull request
Apr 15, 2025
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 *make*subprocess_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 *execute*child
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. I want a NATURAL test that exercises codemcp itself similar to the E2E tests, not a unit test that manually calls the function and triggers an error. Hypothesize how you could get to this error state in the existing codebase before writing the test.
```git-revs
64397ca (Base revision)
641e6f4 Convert NotADirectoryError from warning to hard error
56fe41e Add E2E test for file path vs. directory error
00043d5 Add explicit file path check in git_log tool
c6930d5 Add missing os import in git_log.py
3663dec Add os import to git_diff.py
780c82c Add explicit file path check in git_diff tool
d1737e0 Add os import to git_show.py
00ca5e8 Add explicit file path check in git_show tool
ec6cc53 Add os import to git_blame.py
a233448 Add explicit file path check in git_blame tool
871f76e Auto-commit format changes
abdbc58 Auto-commit lint changes
37b1af5 Replace expecttest import with unittest
7b0b731 Replace expecttest decorator with unittest.expectedFailure
6a34291 Fix test to use RunCommand instead of GitLog
cfa3f0e Fix test_git_diff_with_file_path to use RunCommand
a3f9a14 Fix test_git_show_with_file_path to use RunCommand
c792464 Replace assertion in first test method
eb397ab Replace assertion in second test method
f5149e9 Replace assertion in third test method
ab28ea4 Update comment in first test
b64c375 Rename and update second test method
89550e7 Rename and update third test method
c2dfb6f Update comment in second test
1d0854c Update comment in third test
cfb93d7 Update assertion in first test
1915f6b Update assertion in second test
340aaf5 Update assertion in last test
17ac6a3 Remove expectedFailure decorator since test is now passing
52f884b Rename second test method to be more accurate
HEAD Auto-commit lint changes
```
codemcp-id: 266-fix-convert-git-directory-error-to-hard-error-and-
ghstack-source-id: edb3471
Pull-Request-resolved: #258
ezyang
added a commit
that referenced
this pull request
Apr 15, 2025
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 *make*subprocess_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 *execute*child
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. I want a NATURAL test that exercises codemcp itself similar to the E2E tests, not a unit test that manually calls the function and triggers an error. Hypothesize how you could get to this error state in the existing codebase before writing the test.
```git-revs
64397ca (Base revision)
641e6f4 Convert NotADirectoryError from warning to hard error
56fe41e Add E2E test for file path vs. directory error
00043d5 Add explicit file path check in git_log tool
c6930d5 Add missing os import in git_log.py
3663dec Add os import to git_diff.py
780c82c Add explicit file path check in git_diff tool
d1737e0 Add os import to git_show.py
00ca5e8 Add explicit file path check in git_show tool
ec6cc53 Add os import to git_blame.py
a233448 Add explicit file path check in git_blame tool
871f76e Auto-commit format changes
abdbc58 Auto-commit lint changes
37b1af5 Replace expecttest import with unittest
7b0b731 Replace expecttest decorator with unittest.expectedFailure
6a34291 Fix test to use RunCommand instead of GitLog
cfa3f0e Fix test_git_diff_with_file_path to use RunCommand
a3f9a14 Fix test_git_show_with_file_path to use RunCommand
c792464 Replace assertion in first test method
eb397ab Replace assertion in second test method
f5149e9 Replace assertion in third test method
ab28ea4 Update comment in first test
b64c375 Rename and update second test method
89550e7 Rename and update third test method
c2dfb6f Update comment in second test
1d0854c Update comment in third test
cfb93d7 Update assertion in first test
1915f6b Update assertion in second test
340aaf5 Update assertion in last test
17ac6a3 Remove expectedFailure decorator since test is now passing
52f884b Rename second test method to be more accurate
c24d978 Auto-commit lint changes
6020aa7 Add test using WriteFile with a file path
HEAD Snapshot before auto-test
```
codemcp-id: 266-fix-convert-git-directory-error-to-hard-error-and-
ghstack-source-id: 3df9564
Pull-Request-resolved: #258
ezyang
added a commit
that referenced
this pull request
Apr 15, 2025
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 *make*subprocess_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 *execute*child
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. I want a NATURAL test that exercises codemcp itself similar to the E2E tests, not a unit test that manually calls the function and triggers an error. Hypothesize how you could get to this error state in the existing codebase before writing the test.
```git-revs
64397ca (Base revision)
641e6f4 Convert NotADirectoryError from warning to hard error
56fe41e Add E2E test for file path vs. directory error
00043d5 Add explicit file path check in git_log tool
c6930d5 Add missing os import in git_log.py
3663dec Add os import to git_diff.py
780c82c Add explicit file path check in git_diff tool
d1737e0 Add os import to git_show.py
00ca5e8 Add explicit file path check in git_show tool
ec6cc53 Add os import to git_blame.py
a233448 Add explicit file path check in git_blame tool
871f76e Auto-commit format changes
abdbc58 Auto-commit lint changes
37b1af5 Replace expecttest import with unittest
7b0b731 Replace expecttest decorator with unittest.expectedFailure
6a34291 Fix test to use RunCommand instead of GitLog
cfa3f0e Fix test_git_diff_with_file_path to use RunCommand
a3f9a14 Fix test_git_show_with_file_path to use RunCommand
c792464 Replace assertion in first test method
eb397ab Replace assertion in second test method
f5149e9 Replace assertion in third test method
ab28ea4 Update comment in first test
b64c375 Rename and update second test method
89550e7 Rename and update third test method
c2dfb6f Update comment in second test
1d0854c Update comment in third test
cfb93d7 Update assertion in first test
1915f6b Update assertion in second test
340aaf5 Update assertion in last test
17ac6a3 Remove expectedFailure decorator since test is now passing
52f884b Rename second test method to be more accurate
c24d978 Auto-commit lint changes
6020aa7 Add test using WriteFile with a file path
11cc1b4 Snapshot before auto-test
HEAD Replace complex test with simpler WriteFile test
```
codemcp-id: 266-fix-convert-git-directory-error-to-hard-error-and-
ghstack-source-id: b67108b
Pull-Request-resolved: #258
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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. I want a NATURAL test that exercises codemcp itself similar to the E2E tests, not a unit test that manually calls the function and triggers an error. Hypothesize how you could get to this error state in the existing codebase before writing the test.
codemcp-id: 266-fix-convert-git-directory-error-to-hard-error-and-