Restore a specific file in the Git repository to its state in the last commit. This function undoes changes to the specified file. Args: repo (git.Repo): The Git repository object file_path (str): Path to the file to be restored Returns: None
(repo: git.Repo, file_path: str)
| 178 | |
| 179 | |
| 180 | def git_restore_file(repo: git.Repo, file_path: str) -> None: |
| 181 | """ |
| 182 | Restore a specific file in the Git repository to its state in the last commit. |
| 183 | This function undoes changes to the specified file. |
| 184 | |
| 185 | Args: |
| 186 | repo (git.Repo): The Git repository object |
| 187 | file_path (str): Path to the file to be restored |
| 188 | |
| 189 | Returns: |
| 190 | None |
| 191 | """ |
| 192 | try: |
| 193 | repo.git.restore(file_path) |
| 194 | logger.info(f"Successfully restored file: {file_path}") |
| 195 | except git.GitCommandError as e: |
| 196 | logger.error(f"An error occurred while restoring file {file_path}: {e}") |
| 197 | |
| 198 | |
| 199 | def git_create_checkout_branch(repo: git.Repo, branch: str) -> None: |
searching dependent graphs…