From b0ec8205f371af7e23bf1fe25fe108a88a634c4c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 15 Jul 2023 13:36:57 -0700 Subject: [PATCH] Add pattern to .gitignore if user confirms, by appending it to the existing content of the file. # Aider chat conversation: --- aider/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aider/main.py b/aider/main.py index 00f303281..b7508d4d8 100644 --- a/aider/main.py +++ b/aider/main.py @@ -56,8 +56,10 @@ def check_gitignore(git_root, io): if not io.confirm_ask(f"Add {pat} to .gitignore (recommended)?"): return - updated_ignore = content + "\n" + pat + "\n" - gitignore_file.write_text(updated_ignore, encoding="utf-8") + if not content.endswith("\n"): + content += "\n" + content += pat + "\n" + gitignore_file.write_text(content, encoding="utf-8") def main(args=None, input=None, output=None):