aider: Updated create_temp_repo function to remove tempdir prefix when adding files to the repository.

# Context:
USER: stderr: 'fatal: pathspec 'tmp.benchmark/yacht.py' did not match any files'
we shouldn't pass the tempdir prefix

ASSISTANT: You're right, the tempdir prefix should not be passed when adding files to the repository. Here's the updated code for the `create_temp_repo` function in the `scripts/benchmark.py` file:

```python
scripts/benchmark.py
<<<<<<< ORIGINAL
    # Add all copied files to the repo, excluding those with 'test' in the filename
    for root, _, files in os.walk(tempdir):
        for file in files:
            if "test" not in file:
                repo.git.add(os.path.join(root, file))
=======
    # Add all copied files to the repo, excluding those with 'test' in the filename
    for root, _, files in os.walk(tempdir):
        for file in files:
            if "test" not in file:
                repo.git.add(os.path.relpath(os.path.join(root, file), tempdir))
>>>>>>> UPDATED
```

This change will use `os.path.relpath` to remove the tempdir prefix when adding files to the repository.
This commit is contained in:
Paul Gauthier 2023-06-23 14:03:31 -07:00
parent 3ff798aa5b
commit acd85b2417

View file

@ -28,7 +28,7 @@ def create_temp_repo(dirname, tempdir):
for root, _, files in os.walk(tempdir):
for file in files:
if "test" not in file:
repo.git.add(os.path.join(root, file))
repo.git.add(os.path.relpath(os.path.join(root, file), tempdir))
# Commit with message "initial"
repo.git.commit(m="initial")