(
hook_type: str,
color: bool,
args: Sequence[str],
stdin: bytes,
)
| 212 | |
| 213 | |
| 214 | def _run_ns( |
| 215 | hook_type: str, |
| 216 | color: bool, |
| 217 | args: Sequence[str], |
| 218 | stdin: bytes, |
| 219 | ) -> argparse.Namespace | None: |
| 220 | _check_args_length(hook_type, args) |
| 221 | if hook_type == 'pre-push': |
| 222 | return _pre_push_ns(color, args, stdin) |
| 223 | elif hook_type in 'commit-msg': |
| 224 | return _ns(hook_type, color, commit_msg_filename=args[0]) |
| 225 | elif hook_type == 'prepare-commit-msg' and len(args) == 1: |
| 226 | return _ns(hook_type, color, commit_msg_filename=args[0]) |
| 227 | elif hook_type == 'prepare-commit-msg' and len(args) == 2: |
| 228 | return _ns( |
| 229 | hook_type, color, commit_msg_filename=args[0], |
| 230 | prepare_commit_message_source=args[1], |
| 231 | ) |
| 232 | elif hook_type == 'prepare-commit-msg' and len(args) == 3: |
| 233 | return _ns( |
| 234 | hook_type, color, commit_msg_filename=args[0], |
| 235 | prepare_commit_message_source=args[1], commit_object_name=args[2], |
| 236 | ) |
| 237 | elif hook_type in {'post-commit', 'pre-merge-commit', 'pre-commit'}: |
| 238 | return _ns(hook_type, color) |
| 239 | elif hook_type == 'post-checkout': |
| 240 | return _ns( |
| 241 | hook_type, color, |
| 242 | from_ref=args[0], to_ref=args[1], checkout_type=args[2], |
| 243 | ) |
| 244 | elif hook_type == 'post-merge': |
| 245 | return _ns(hook_type, color, is_squash_merge=args[0]) |
| 246 | elif hook_type == 'post-rewrite': |
| 247 | return _ns(hook_type, color, rewrite_command=args[0]) |
| 248 | elif hook_type == 'pre-rebase' and len(args) == 1: |
| 249 | return _ns(hook_type, color, pre_rebase_upstream=args[0]) |
| 250 | elif hook_type == 'pre-rebase' and len(args) == 2: |
| 251 | return _ns( |
| 252 | hook_type, color, pre_rebase_upstream=args[0], |
| 253 | pre_rebase_branch=args[1], |
| 254 | ) |
| 255 | else: |
| 256 | raise AssertionError(f'unexpected hook type: {hook_type}') |
| 257 | |
| 258 | |
| 259 | def hook_impl( |
no test coverage detected