-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Don't try to add ignored files to git. #196
Conversation
Results in a git error and an exception otherwise.
(was merged into the first comment) |
User ExperienceWhen an ignored file isn't added, can you print a message explaining why for the user? This improves perceived transparency. Something like:
TestingHere is how I would adjust the test case to add to the def test_add_new_files_ignored(self):
# Configure git to show ignored file warnings
self.repo.git.config("advice.addIgnoredFile", "false")
# Add some entries to the .gitignore
with open(self.repo.working_dir / ".gitignore", "w") as f:
f.write("ignored.txt\n")
# Try to add an ignored file
self.repo.add_new_files(["ignored.txt"])
# Verify the ignored file was not added
tracked_files = self.repo.get_tracked_files()
self.assertNotIn("ignored.txt", tracked_files) The key points:
This follows the same overall pattern as the other tests - use the repo instance, call the method being tested, and assert the expected behavior. Let me know if you have any other questions! |
Something from the human 😅. I wonder if sometimes it expected to add ignored files, will be cool for /add command to have some argument like git add has e.g. "--force". But it probably can be next milestone, if there will be demand from users. |
@buger why should this happen? Did you think it through? It creates unneccessary noise. Maybe in different use cases. If I tell aider to add the file to git, it would maybe help to get a message. But in my case I simply want to work on the file. Maybe you want to explain to me how I could distinguish the 2 cases in the code. |
Maybe I am understanding aider wrong. I can work on all files as a human, and aider should also be able to work on all files and see them, especially if I tell it to use them. But only files that are not ignored should be tracked by git. Or otherwise, how would I give aider information from files that are git ignored? |
I found more problems with the proposed change. Aider can no longer list and understand which files are in git. I believe now aider was built around the idea that files it can edit and files in the git repo are basically the same. I am closing this. |
@kwmiebach im not official contribution or owner of this repo, so take my words and thoughts with a bit of salt. Overall idea of this pr totally makes sense. But sometimes ignored files are not just some config files or similar, it can be code which you do not want be changed, e.g it’s in repo but can’t be easily changed. |
If I start aider with a file that is in .gitignore and should be ignored by git, aider tries nonetheless to
git add
the file. I think this is an obvious bug.Old behaviour:
Let's say files aa and bb are in
.gitignore
:Now let's say the user starts aider and gives aa and bb as file parameters:
The old behaviour is that aider will immediateley try to
git add
both files. And this results in a python exception:In the other case, if a file is not git-ignored and it is also not part of the git index, aider will correctly add it to git:
Example for untracked file (not ignored):
In the proposed fix, before
git adding
a file, the code would use therepo.ignored()
check and if the file is ignored it would not try to add the file to git:But there is a small issue with this solution:
/ls
does not list aa and bb. I could not find out why. So while my proposed change fixeds one obvious thing, it introduces another problem.