diff --git a/github_scripts/get_git_sources.py b/github_scripts/get_git_sources.py index f9fe168e..ffee9652 100644 --- a/github_scripts/get_git_sources.py +++ b/github_scripts/get_git_sources.py @@ -19,6 +19,19 @@ logger = logging.getLogger(__name__) +class SubprocessRunError(Exception): + def __init__(self, command, returncode, stdout, stderr): + self.command = command + self.returncode = returncode + self.stdout = stdout + self.stderr = stderr + self.message = ( + f"Errorcode {returncode} raised when running command '{command}\n\n" + f"stdout:\n{stdout}\n\nstderr:\n{stderr}" + ) + super().__init__(self.message) + + def run_command( command: str, check: bool = True, capture: bool = True, timeout: int = 600 ) -> Optional[subprocess.CompletedProcess]: @@ -44,8 +57,8 @@ def run_command( if check and result.returncode != 0: err_msg = (result.stderr or "").strip() logger.error(f"[FAIL] Command failed: {command}\nError: {err_msg}") - raise subprocess.CalledProcessError( - result.returncode, args, output=result.stdout, stderr=result.stderr + raise SubprocessRunError( + result.returncode, command, result.stdout, result.stderr ) return result @@ -198,14 +211,14 @@ def merge_source( run_command(f"git -C {dest} fetch local {fetch}") - command = f"git -C {dest} merge --no-gpg-sign FETCH_HEAD" + command = f"git -C {dest} merge --no-gpg-sign --no-edit FETCH_HEAD" result = run_command(command, check=False) if result.returncode: unmerged_files = get_unmerged(dest) if unmerged_files: handle_merge_conflicts(source, ref, dest, dest.name) else: - raise subprocess.CalledProcessError( + raise SubprocessRunError( result.returncode, command, result.stdout, result.stderr ) diff --git a/github_scripts/merge_sources.py b/github_scripts/merge_sources.py index acb63c22..9f884911 100755 --- a/github_scripts/merge_sources.py +++ b/github_scripts/merge_sources.py @@ -32,6 +32,7 @@ def parse_args(): parser.add_argument( "-p", "--path", + type=Path, default=None, help="The path to extract the sources to. If part of a cylc suite, it will " "default to $CYLC_WORKFLOW_SHARE_DIR/source, otherwise __file__/source", diff --git a/github_scripts/suite_report_git.py b/github_scripts/suite_report_git.py index 5bf32254..340110c4 100755 --- a/github_scripts/suite_report_git.py +++ b/github_scripts/suite_report_git.py @@ -238,7 +238,7 @@ def create_um_config_owner_table(self, owners: Dict) -> None: # Create a dict with owners as the key table_dict = defaultdict(list) for config in failed_configs: - owner, others = owners[config] + owner, others = owners.get(config, "UNKNOWN") if others != "--": config = f"{config} ({others})" table_dict[owner].append(config)