Skip to content
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

Various fixes #355

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pilot/helpers/AgentConvo.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,13 @@ def escape_specials(self, s):
return s

def replace_file_content(self, message, file_path, new_content):
escaped_file_path = re.escape(file_path)

pattern = rf'\*\*{escaped_file_path}\*\*:\n```\n(.*?)\n```'
pattern = rf'\*\*{re.escape(file_path)}\*\*:\n```\n(.*?)\n```'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just removes escape_file_path variable to avoid confusion with similarly-named but differently escaped file path a few lines below. No changes to the pattern.


# Escape special characters in new_content for the sake of regex replacement
new_content_escaped = self.escape_specials(new_content)
file_path_escaped = self.escape_specials(file_path)

new_section_content = f'**{file_path}**\n```\n{new_content_escaped}\n```'
new_section_content = f'**{file_path_escaped}**\n```\n{new_content_escaped}\n```'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows paths have plenty of occurrences of \ which were not escaped in a recent change to this.


updated_message, num_replacements = re.subn(pattern, new_section_content, message, flags=re.DOTALL)

Expand Down
2 changes: 1 addition & 1 deletion pilot/helpers/Project.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def start(self):
print('yes/no', type='button')
should_overwrite_files = styled_text(
self,
f'Do you want to overwrite the dev step {self.args["skip_until_dev_step"]} code with system changes? Type y/n',
"Can I overwrite any changes that you might have made to the project since last running GPT Pilot (y/n)?",
ignore_user_input_count=True
)

Expand Down
6 changes: 5 additions & 1 deletion pilot/logger/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ def setup_logger():
log_format = "%(asctime)s [%(filename)s:%(lineno)s - %(funcName)20s() ] %(levelname)s: %(message)s"

# Create a log handler for file output
file_handler = logging.FileHandler(filename=os.path.join(os.path.dirname(__file__), 'debug.log'), mode='w')
file_handler = logging.FileHandler(
filename=os.path.join(os.path.dirname(__file__), 'debug.log'),
mode='w',
encoding='utf-8',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding encoding so logging doesn't crash on Windows when there are characters which don't fit into whatever code page is active by default.

)

# Apply the custom format to the handler
formatter = logging.Formatter(log_format)
Expand Down