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

Various fixes #355

merged 1 commit into from
Dec 10, 2023

Conversation

senko
Copy link
Contributor

@senko senko commented Dec 10, 2023

  • fix Windows file path escaping in file modifications
  • be explicit about the log code page (also helps for Windows)
  • improve file overwrite message

@senko senko requested a review from LeonOstrez December 10, 2023 11:17
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.


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.

@@ -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',
f"Can I overwrite any changes that you might have made to the project since last running GPT Pilot (y/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.

Unrelated to other changes, this is just a rewording of the message because the previous one is really unclear even to people who work on GPT Pilot (ie. me 😄 ).

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.

* fix Windows file path escaping in file modifications
* be explicit about the log code page (also helps for Windows)
* improve file overwrite message
@LeonOstrez LeonOstrez merged commit 30582fc into main Dec 10, 2023
6 checks passed
@senko senko deleted the senko-fixes branch December 10, 2023 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants