o
    Wi.>                     @  s  d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlm	Z
 d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dl m!Z! d dl"m#Z# d dl$m%Z% d dl&m'Z' d dl(m)Z) d dl*m+Z+ d dl,m-Z- d dl.m/Z/ d dl0m1Z1 e2dZ3ej45dd ej45dd h dZ6d1d!d"Z7d1d#d$Z8d1d%d&Z9d2d)d*Z:d3d4d.d/Z;e<d0kre=e; dS )5    )annotationsN)Sequence)	clientlib)git)add_color_option)hazmat)
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__PYTHONEXECUTABLE>   r
   r	   r   sample-configvalidate-configinit-templatedirvalidate-manifestparserargparse.ArgumentParserreturnNonec                 C  s   | j ddtjdd d S )Nz-cz--configzPath to alternate config file)defaulthelp)add_argumentCCONFIG_FILEr     r*   C/home/ubuntu/.local/lib/python3.10/site-packages/pre_commit/main.py_add_config_option2   s   
r,   c                 C  s   | j ddtjddd d S )Nz-t--hook-typeappend
hook_types)choicesactiondest)r&   r   
HOOK_TYPESr)   r*   r*   r+   _add_hook_type_option9   s   
r4   c                 C  sX  | j dddd | j dddd | jd	d
}|j ddddd |j ddg dd | j dddd | j dddd | j dtjtjddd | j ddd | j ddd | j d d!d"d#d | j d$d%d&d'd | j d(d)d | j d*d+d | j d,d-d | j d.d/d | j d0d1d | j d2d3d | j d4d5d | j d6d7d | j d8d9d | j d:d;d d S )<Nhook?zA single hook-id to runnargsr%   z	--verbosez-v
store_truer1   F)requiredz--all-filesz-az!Run on all the files in the repo.r1   r%   z--files*z#Specific filenames to run hooks on.)r8   r$   r%   z--show-diff-on-failurez3When hooks fail, run `git diff` directly afterward.z--fail-fastz"Stop after the first failing hook.z--hook-stage
pre-commitz=The stage during which the hook is fired.  One of %(choices)s)r0   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-namezRemote name used by `git push`.z--remote-urlzRemote 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_groupr   STAGEStransform_stage)r    mutex_groupr*   r*   r+   _add_run_options@   s   

rE   argsargparse.Namespacec                 C  s  t j| jrt j| j| _| jdv r*dd | jD | _| jd ur*t j| j| _| jdkr>t j| jr>t j| j| _t	
 }t | t j| j| _| jdv rjdd | jD | _| jd urjt j| j| _| jdkrt j| jrt j| j| _d S d S d S )N>   r   try-repoc                 S     g | ]}t j|qS r*   )ospathabspath.0filenamer*   r*   r+   
<listcomp>       z*_adjust_args_and_chdir.<locals>.<listcomp>rH   c                 S  rI   r*   )rJ   rK   relpathrM   r*   r*   r+   rP      rQ   )rJ   rK   existsconfigrL   commandfilescommit_msg_filenamerepor   get_rootchdirrR   )rF   toplevelr*   r*   r+   _adjust_args_and_chdir   s,   




r\   argvSequence[str] | Noneintc                   s  | d ur| nt jdd  } tjdd}|jddddtj d |jd	d
 dl fdd}|ddd}t| |jdddd |jdddd |jddddg dd  |jd!d"t	dd#d$ |d%d&d |d'd(d |d)d*d}t
| |d+d,d}t| |jd-d.d |jd/d0d1d2d3 t| |d4d5d}t| |jd6d7dd8d |jd9dd:d t| |jd;dd<d |d=d>d}t| |d?d@d}t| |dAdBd}	t|	 t|	 |dCdDtj dEd |dFdGd}
t|
 |
jdHdId |
jdJdKdLd t|
 |dMdNd}t| t| |dOdPd}|jdQdRdS |dTdUd}|jdQdRdS  jddVd}|jdWdXdYdZ  d[}t| t| |d\ |d] |jd^dd_ |jd`tjda t| dbkridAg} || }|jdkr|jr||jdcg n|jdkr|dcg t  t|j t  t }|jtvrt| ||j |jdkrt |j|j! |j"|j#|j$ddW  d    W  d    S |jd%krt%|W  d    W  d    S |jd'krt&|W  d    W  d    S |jd)krt
'|W  d    W  d    S |jd[krEt(||j|j|j)|j*|j+|j,dd  deW  d    W  d    S |jd4krht-|j||j.|j/|j0|j1dfW  d    W  d    S |jd+krt2|j||j3|j.|j1dgW  d    W  d    S |jd=krt0|j|W  d    W  d    S |jd?krt4|jW  d    W  d    S |jdAkrt5|j||W  d    W  d    S |jdCkrt6 W  d    W  d    S |jdFkrt7|W  d    W  d    S |jdMkr"t8|j|j.dhW  d    W  d    S |jdOkr;t9|j:W  d    W  d    S |jdTkrTt;|j:W  d    W  d    S t<di|j dj1 saw   Y  W d    d S 1 srw   Y  d S )mN   r>   )progz-Vz	--versionversionz	%(prog)s )r1   rb   rU   )r2   namestrr%   r"   r!   c                  s    j | |d}t| |S )Nr@   )
add_parserr   )rc   r%   r    
subparsersr*   r+   _add_cmd   s   zmain.<locals>._add_cmdr   z<Auto-update pre-commit config to the latest repos' versions.r@   z--bleeding-edger9   zbUpdate to the bleeding edge of `HEAD` instead of the latest tagged version (the default behavior).r<   z--freezez3Store "frozen" hashes in `rev` instead of tag namesz--reporeposr.   REPOz?Only update this repository -- may be specified multiple times.)r2   r1   metavarr$   r%   z-jz--jobsz1Number of threads to use.  (default %(default)s).)r?   r$   r%   r	   zClean out pre-commit files.r
   zClean unused cached repos.r   z.Composable tools for rare use in hook `entry`.r   zWInstall hook script in a directory intended for use with `git config init.templateDir`.	directoryz0The directory in which to write the hook script.z--no-allow-missing-configstore_falseallow_missing_configz6Assume cloned repos should have a `pre-commit` config.)r1   r2   r%   r   zInstall the pre-commit script.z-fz--overwritez1Overwrite existing hooks / remove migration mode.z--install-hookszMWhether to install hook environments for all environments in the config file.z--allow-missing-configzWWhether to allow a missing `pre-commit` configuration file or exit with a failure code.zinstall-hookszInstall hook environments for all environments in the config file.  You may find `pre-commit install --install-hooks` more useful.zmigrate-configz4Migrate list configuration to new map configuration.r   z
Run hooks.r   zProduce a sample z filerH   z?Try the hooks in a repository, useful for developing new hooks.rX   z Repository to source hooks from.z--refz--revzQManually select a rev to run against, otherwise the `HEAD` revision will be used.r   z Uninstall the pre-commit script.r   z&Validate .pre-commit-config.yaml files	filenamesr=   )r8   r   z%Validate .pre-commit-hooks.yaml filesz!Show help for a specific command.help_cmdr6   zCommand to show help for.r7   z	hook-implr-   z
--hook-dirz--skip-on-missing-configr:   rest)r2   r8   r   z--help)	tags_onlyfreezeri   jobs)rT   color	hook_typehook_dirskip_on_missing_configrF   )r/   	overwritehooksrx   )r/   rx   )config_filer/   zCommand z not implemented.z! failed to exit with a returncode)rc   rd   r%   rd   r"   r!   )>sysr]   argparseArgumentParserr&   r'   VERSIONadd_subparsersr,   r_   r   add_parsersr4   rE   r(   re   r   	REMAINDERlen
parse_argsrU   rp   r   r   ru   r   check_for_cygwin_mismatchr   COMMANDS_NO_GITr\   mark_config_usedrT   r   bleeding_edgers   ri   rt   r	   r
   implr   rv   rw   rx   rq   r   r/   ry   r   rn   r   rl   r   r   r   r   r   r   ro   r   NotImplementedErrorAssertionError)r]   r    rh   autoupdate_parserhazmat_parserinit_templatedir_parserinstall_parserinstall_hooks_parsermigrate_config_parser
run_parsertry_repo_parseruninstall_parservalidate_config_parservalidate_manifest_parserr%   hook_impl_parserrF   storer*   rf   r+   main   s  






!)
/
13579>@C8r   __main__)r    r!   r"   r#   )rF   rG   r"   r#   )N)r]   r^   r"   r_   )>
__future__r   r}   loggingrJ   r|   collections.abcr   pre_commit.constants	constantsr'   r   r   r   pre_commit.colorr   pre_commit.commandsr   pre_commit.commands.autoupdater   pre_commit.commands.cleanr	   pre_commit.commands.gcr
   pre_commit.commands.hook_implr   $pre_commit.commands.init_templatedirr   %pre_commit.commands.install_uninstallr   r   r   "pre_commit.commands.migrate_configr   pre_commit.commands.runr   !pre_commit.commands.sample_configr   pre_commit.commands.try_repor   #pre_commit.commands.validate_configr   %pre_commit.commands.validate_manifestr   pre_commit.error_handlerr   pre_commit.logging_handlerr   pre_commit.storer   	getLoggerloggerenvironpopr   r,   r4   rE   r\   r   __name__
SystemExitr*   r*   r*   r+   <module>   sR    




o |
