Open the message in the git editor and return the edited message. The temporary file uses `commit_encoding` (or `encoding`) instead of the locale encoding. On Windows, the locale encoding is a legacy code page that cannot encode all characters. Raises: R
(self, message: str)
| 139 | return "\n".join(chain(lines[:2], wrapped_body_lines)) |
| 140 | |
| 141 | def manual_edit(self, message: str) -> str: |
| 142 | """Open the message in the git editor and return the edited message. |
| 143 | |
| 144 | The temporary file uses `commit_encoding` (or `encoding`) instead of the |
| 145 | locale encoding. On Windows, the locale encoding is a legacy code page |
| 146 | that cannot encode all characters. |
| 147 | |
| 148 | Raises: |
| 149 | RuntimeError: If no editor is set or the editor is not found. |
| 150 | """ |
| 151 | editor = git.get_core_editor() |
| 152 | if editor is None: |
| 153 | raise RuntimeError("No 'editor' value given and no default available.") |
| 154 | exec_path = shutil.which(editor) |
| 155 | if exec_path is None: |
| 156 | raise RuntimeError(f"Editor '{editor}' not found.") |
| 157 | encoding = self._get_commit_encoding() |
| 158 | with tempfile.NamedTemporaryFile( |
| 159 | mode="w", delete=False, encoding=encoding |
| 160 | ) as file: |
| 161 | file.write(message) |
| 162 | file_path = file.name |
| 163 | argv = [exec_path, file_path] |
| 164 | subprocess.call(argv) |
| 165 | message = Path(file_path).read_text(encoding=encoding).strip() |
| 166 | os.unlink(file.name) |
| 167 | return message |
| 168 | |
| 169 | def _get_message(self) -> str: |
| 170 | if self.arguments.get("retry"): |