U ej<@sddlmZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/e0dZ1ej23ddddddddhZ4d d!d"d#d$Z5d d!d"d%d&Z6d d!d"d'd(Z7d)d!d*d+d,Z8d3d-d.d/d0d1Z9e:d2kre;e9dS)4) annotationsN)Sequence) clientlib)git)add_color_option) autoupdate)clean)gc) hook_impl)init_templatedir)install) install_hooks) uninstall)migrate_config)run) sample_config)try_repo)validate_config)validate_manifest) error_handler)logging_handler)Store pre_commit__PYVENV_LAUNCHER__rr init-templatedir sample-configvalidate-configvalidate-manifestargparse.ArgumentParserNone)parserreturncCs|jddtjdddS)Nz-cz--configzPath to alternate config file)defaulthelp) add_argumentC CONFIG_FILEr r(=/opt/hc_python/lib/python3.8/site-packages/pre_commit/main.py_add_config_option.s r*cCs|jddtjddddS)Nz-t --hook-typeappend hook_types)choicesactiondest)r$rZ HOOK_TYPESr'r(r(r)_add_hook_type_option5sr1cCsL|jdddd|jddddd |jdd }|jd d ddd d|jddgdd|jdddd|jdtjtjddd|jddd|jddd|jdd d!d"d|jd#d$d%d&d|jd'd(d|jd)d*d|jd+d,d|jd-d.d|jd/d0d|jd1d2d|jd3d4d|jd5d6d|jd7d8d|jd9d:ddS);Nhook?zA single hook-id to runnargsr#z --verbosez-v store_trueF)r/r")requiredz --all-filesz-az!Run on all the files in the repo.r/r"r#z--files*z#Specific filenames to run hooks on.)r5r"r#z--show-diff-on-failurez3When hooks fail, run `git diff` directly afterward.r/r#z --hook-stage pre-commitz=The stage during which the hook is fired. One of %(choices)s)r.typer"r#z--remote-branchz%Remote branch ref used by `git push`.r#z--local-branchz$Local branch ref used by `git push`.z --from-refz--sourcez-sa(for usage with `--to-ref`) -- this option represents the original ref in a `from_ref...to_ref` diff expression. For `pre-push` hooks, this represents the branch you are pushing to. For `post-checkout` hooks, this represents the branch that was previously checked out.z--to-refz--originz-oa(for usage with `--from-ref`) -- this option represents the destination ref in a `from_ref...to_ref` diff expression. For `pre-push` hooks, this represents the branch being pushed. For `post-checkout` hooks, this represents the branch that is now checked out.z--pre-rebase-upstreamz.The upstream from which the series was forked.z--pre-rebase-branchzKThe branch being rebased, and is not set when rebasing the current branch.z--commit-msg-filenamez2Filename to check when running during `commit-msg`z--prepare-commit-message-sourcez]Source of the commit message (typically the second argument to .git/hooks/prepare-commit-msg)z--commit-object-namezRCommit object name (typically the third argument to .git/hooks/prepare-commit-msg)z --remote-namezRemote name used by `git push`.z --remote-urlzRemote url used by `git push`.z--checkout-typezIndicates whether the checkout was a branch checkout (changing branches, flag=1) or a file checkout (retrieving a file from the index, flag=0).z--is-squash-mergezHDuring a post-merge hook, indicates whether the merge was a squash mergez--rewrite-commandzJDuring a post-rewrite hook, specifies the command that invoked the rewrite)r$add_mutually_exclusive_grouprZSTAGESZtransform_stage)r mutex_groupr(r(r)_add_run_options<s   r@zargparse.Namespace)argsr!cCstj|jrtj|j|_|jdkrTdd|jD|_|jdk rTtj|j|_|jdkr|tj|jr|tj|j|_t }t |tj |j|_|jdkrdd|jD|_|jdk rtj |j|_|jdkrtj|jrtj |j|_dS)N>try-reporcSsg|]}tj|qSr()ospathabspath.0filenamer(r(r) sz*_adjust_args_and_chdir..rBcSsg|]}tj|qSr()rCrDrelpathrFr(r(r)rIs) rCrDexistsconfigrEcommandfilesZcommit_msg_filenamereporZget_rootchdirrJ)rAtoplevelr(r(r)_adjust_args_and_chdirs*     rRzSequence[str] | Noneint)argvr!c sn|dk r |n tjdd}tjdd}|jddddtjd|jd d d d d d fdd }|ddd}t||jdddd|jdddd|jddddgdd|jdd t dd!d"|d#d$d|d%d&d|d'd(d}t||jd)d*d|jd+d,d-d.d/t ||d0d1d}t||jd2d3dd4d|jd5dd6dt ||jd7dd8d9d:|d;dd}t||d?d@d}t|t ||dAdBtj dCd|dDdEd} t| | jdFdGd| jdHdIdJdt | |dKdLd} t| t | |dMdNd} | jdOdPdQ|dRdSd} | jdOdPdQj dTdUd} | jdVdWdXdY dZ}t|t||d[|d\|jd]dd^|jd_tjd`t|dakrd?g}||}|jdTkr|jr||jdbgn|jdTkr|dbgtNt|j6tt}|jtkrTt|||j|jdkrt|j|j |j |j!|j"dcW5QRW5QRS|jd#krt#|W5QRW5QRS|jd%krt$|W5QRW5QRS|jdZkr._add_cmdrzsV                        ku