Clean up temporary branch and restore original branch.
(self)
| 852 | self.warnings.append(error_msg) |
| 853 | |
| 854 | def cleanup_temp_branch(self): |
| 855 | """Clean up temporary branch and restore original branch.""" |
| 856 | if not self.temp_branch: |
| 857 | return |
| 858 | |
| 859 | print(f"\nCleaning up temporary branch: {self.temp_branch}") |
| 860 | |
| 861 | # Restore original branch |
| 862 | if self.current_branch: |
| 863 | #print(f" Restoring branch: {self.current_branch}") |
| 864 | result = self.run_git(["checkout", self.current_branch], check=False) |
| 865 | self._print_git_status(f"Restored branch: {self.current_branch}", result) |
| 866 | else: |
| 867 | print(" Warning: Could not determine original branch") |
| 868 | |
| 869 | # Delete temporary branch |
| 870 | #print(f" Deleting temporary branch: {self.temp_branch}") |
| 871 | result = self.run_git(["branch", "-D", self.temp_branch], check=False) |
| 872 | self._print_git_status(f"Deleted temporary branch: {self.temp_branch}", result) |
| 873 | |
| 874 | # Clean up working directory |
| 875 | #print(f" Cleaning up working directory") |
| 876 | result = self.run_git(["reset", "--hard"], check=False) |
| 877 | if result.returncode == 0: |
| 878 | result = self.run_git(["clean", "-fd"], check=False) |
| 879 | self._print_git_status("Cleaned up working directory", result) |
| 880 | |
| 881 | @staticmethod |
| 882 | def _get_branch_type(branch_info: BranchInfo) -> str: |
no test coverage detected