11"""Helper class for Git repo operations."""
2+
3+ PARENT_DIR = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '../ReleaseAutomation' ))
4+ sys .path .insert (0 , PARENT_DIR )
5+
26import subprocess
37import sys
48import os
59from git import Repo , Actor
610from github import GithubException
7-
8- PARENT_DIR = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '../ReleaseAutomation' ))
9- sys .path .insert (0 , PARENT_DIR )
10-
1111from release_config import ReleaseConfig
1212
1313def get_local_repo ():
@@ -35,10 +35,10 @@ def get_latest_git_revision(branch_name):
3535 )
3636 return result .stdout .strip ()
3737
38- except FileNotFoundError :
39- raise Exception ("Git command not found. Please ensure Git is installed and available in your PATH." )
38+ except FileNotFoundError as exc :
39+ raise Exception ("Git command not found. Please ensure Git is installed and available in your PATH." ) from exc
4040 except subprocess .CalledProcessError as e :
41- raise Exception (f"Failed to get the latest revision for branch '{ branch_name } '." )
41+ raise Exception (f"Failed to get the latest revision for branch '{ branch_name } '." ) from e
4242
4343def create_branch_execute_commands_and_push (config : ReleaseConfig ):
4444 """
@@ -57,7 +57,7 @@ def create_branch_execute_commands_and_push(config: ReleaseConfig):
5757
5858 if config .command_to_run_on_release_branch :
5959 print (f"\n Executing command on branch '{ config .release_branch_name } ': { ' ' .join (config .command_to_run_on_release_branch .__name__ )} " )
60- config .command_to_run_on_release_branch (config .manifest_path , config .changelog_path , config .validation_exceptions_path , config .package_version )
60+ config .command_to_run_on_release_branch (config .manifest_path , config .changelog_path , config .validation_exceptions_path , config .package_version , config . package_name_regex )
6161
6262 repo .git .add ('.yamato/' ) # regenerated jobs
6363 repo .git .add ('Packages/' ) # for example changelog and package.json updates
@@ -72,6 +72,6 @@ def create_branch_execute_commands_and_push(config: ReleaseConfig):
7272 print (f"Successfully created, updated and pushed new branch: { config .release_branch_name } " )
7373
7474 except GithubException as e :
75- raise GithubException (f"An error occurred with the GitHub API: { e .status } " , data = e .data )
75+ raise GithubException (f"An error occurred with the GitHub API: { e .status } " , data = e .data ) from e
7676 except Exception as e :
77- raise Exception (f"An unexpected error occurred: { e } " )
77+ raise Exception (f"An unexpected error occurred: { e } " ) from e
0 commit comments