Ë
    ›¾j¡  ã                   ó$  — d dl Z d dlZd dlmZ d dlmZ d dlZd dlmZ ddl	m
Z
 ddlmZmZmZmZ dd	lmZmZmZmZmZmZ e
j.                  Ze
j2                  Zd
dgZ ej8                  d«       edd¬«       eddd¬«       eeddd¬«       edddddj;                  e«      › �¬«       edddd¬«      fdej<                  dedee   d ed!ee   d"e fd#„«       Z!e
j.                  e
j2                  ded$œdeded ed!ed"e d%ed&dfd'„Z"deded ed&dfd(„Z#y))é    N)ÚPath)ÚOptional)Úmsgé   )Úabout)Úensure_pathÚget_git_versionÚgit_checkoutÚgit_repo_branch_existsé   )ÚCOMMANDÚPROJECT_FILEÚArgÚOptÚ_get_parent_commandÚappÚmainÚmasterÚclone.z!The name of the template to clone)ÚhelpzAWhere to clone the project. Defaults to current working directoryF)r   Úexistsz--repoz-rzThe repository to clone fromz--branchz-bz8The branch to clone from. If not provided, will attempt ú, z--sparsez-SzZUse sparse Git checkout to only check out and clone the files needed. Requires Git v22.2+.ÚctxÚnameÚdestÚrepoÚbranchÚsparse_checkoutc                 óâ  — |€-t        j                  «       t        |«      j                  d   z  }|t        k(  r|€t        }|€Ut
        D ]  }t        ||«      sŒ|} n |€bdj                  d„ t
        D «       «      }t        j                  d|› d�d¬«       n*t        ||«      st        j                  d	|› d
|› d�d¬«       t        |t        «      sJ ‚t        | «      }t        ||||||¬«       y)aW  Clone a project template from a repository. Calls into "git" and will
    only download the files from the given subdirectory. The GitHub repo
    defaults to the official Weasel template repo, but can be customized
    (including using a private repo).

    DOCS: https://github.com/explosion/weasel/tree/main/docs/cli.md#clipboard-clone
    Néÿÿÿÿr   c              3   ó(   K  — | ]
  }d |› d �–— Œ y­w)ú'N© )Ú.0Úbs     úZ/home/spazio/kingdom_calls/work5/transenv/lib/python3.12/site-packages/weasel/cli/clone.pyú	<genexpr>z$project_clone_cli.<locals>.<genexpr>/   s   è ø€ Ò,P¸!¨q°°°1¬XÑ,Pùs   ‚z2No branch provided and attempted default branches z do not exist.r   ©Úexitszrepo: z
 (branch: z) does not exist.©r   r   r   Úparent_command)r   ÚcwdÚpartsÚDEFAULT_REPOÚDEFAULT_PROJECTS_BRANCHÚDEFAULT_BRANCHESr   Újoinr   ÚfailÚ
isinstanceÚstrr   Úproject_clone)	r   r   r   r   r   r   Údefault_branchÚdefault_branches_msgr+   s	            r&   Úproject_clone_clir8      sü   € ð$ €|Ü�x‰x‹zœD ›J×,Ñ,¨RÑ0Ñ0ˆØŒ|Ò  Ü(ˆà€~Ü.ò 	ˆNÜ% d¨NÕ;Ø'�Ùð	ð ˆ>Ø#'§9¡9Ñ,PÔ?OÔ,PÓ#PÐ Ü�H‰HðØ0Ð1°ðAàöô & d¨FÔ3Ü�H‰H�v˜d˜V :¨f¨XÐ5FÐGÈqÕQÜ�fœcÔ"Ð"Ð"Ü(¨Ó-€NÜØØØØØ'Ø%öó    r*   r+   Úreturnc          	      ó  — t        |«      }t        | ||«       |j                  «       }t        j                  dd|«      }	 t        || |||¬«       t        j                  d
| › d|› d|› d�|«       |t        z  j                  «       st        j                  dt        › d�«       yt        j                  d«       t        d|› d|› �«       y# t        j                  $ r& d| › d|› d|› d�}t        j                  |d¬	«       Y Œ´w xY w)zþClone a project template from a repository.

    name (str): Name of subdirectory to clone.
    dest (Path): Destination path of cloned project.
    repo (str): URL of Git repo containing project templates.
    branch (str): The branch to clone from
    z(http(s?)):\/\/github.com/Ú )r   ÚsparsezCould not clone 'z' from repo 'z' (branch 'z')r   r(   zCloned 'z' from 'zNo z found in directoryzYour project is now ready!zTo fetch the assets, run:
z assets N)r   Úcheck_cloneÚresolveÚreÚsubr
   Ú
subprocessÚCalledProcessErrorr   r2   Úgoodr   r   ÚwarnÚprint)	r   r   r   r   r   r+   Úproject_dirÚ	repo_nameÚerrs	            r&   r5   r5   D   sý   € ô  �tÓ€DÜ��d˜DÔ!Ø—,‘,“.€KÜ—‘Ð4°b¸$Ó?€IðÜ�T˜4 ¨f¸_ÕMô ‡H�Hˆx˜�v˜X i [°¸F¸8À2ÐFÈÔTØœ,Ñ&×.Ñ.Ô0Ü�‰�3”|�nÐ$7Ð8Õ9ä�‰Ð-Ô.ÜÐ+¨NÐ+;¸8ÀDÀ6ÐJÕKøô ×(Ñ(ò Ø! $  }°Y°K¸{È6È(ÐRTÐUˆÜ�‰�˜A×ðús   ÁC Ã6DÄDc                 ó@  — d| › d|› d|› d�}t        |¬«       |st        j                  d|› �d¬«       |j                  «       rt        j                  d	|› �d¬«       |j                  j                  «       s&t        j                  d
|j                  › d�d¬«       yy)a=  Check and validate that the destination path can be used to clone. Will
    check that Git is available and that the destination path is suitable.

    name (str): Name of the directory to clone from the repo.
    dest (Path): Local destination of cloned directory.
    repo (str): URL of the repo to clone from.
    z~Cloning Weasel project templates requires Git and the 'git' command. To clone a project without Git, copy the files from the 'z' directory in the z to z
 manually.)Úerrorz(Not a valid directory to clone project: r   r(   z/Can't clone project, directory already exists: z5Can't clone project, parent directory doesn't exist: z9. Create the necessary folder(s) first before continuing.N)r	   r   r2   r   Úparent)r   r   r   Úgit_errs       r&   r>   r>   e   s©   € ðDØDHÀ6ð JØ ˜6  d V¨:ð	7ð ô
 ˜'Õ"ÙÜ�‰Ð;¸D¸6ÐBÈ!ÕLØ‡{�{„}ä�‰ÐBÀ4À&ÐIÐQRÕSØ�;‰;×ÑÔä�‰ØCÀDÇKÁKÀ=ð QFð Gàö	
ð  r9   )$r@   rB   Úpathlibr   Útypingr   ÚtyperÚwasabir   r<   r   Úutilr   r	   r
   r   r   r   r   r   r   r   r   Ú__projects__r.   Ú__projects_branch__r/   r0   Úcommandr1   ÚContextr4   Úboolr8   r5   r>   r#   r9   r&   ú<module>rX      s¶  ðÛ 	Û Ý Ý ã Ý å ß UÓ Uß K× Kà×!Ñ!€Ø×3Ñ3Ð Ø˜HÐ%Ð ð €‡�ˆWÓñ �CÐAÔBÙ˜tÐ*mÐv{Ô|Ù�L (¨DÐ7UÔVÙ  j°$Ð?wÐx|÷  yBñ  yBð  CSó  yTð  xUð  >Vô  WÙ  z°4ð  ?[ô  \ñ.à	�‰ð.ð ð.ð �4‰.ð	.ð
 ð.ð �S‰Mð.ð ò.ó ð.ðj ×"Ñ"Ø×+Ñ+Ø!Ø!òLØ
ðLà
ðLð ð	Lð
 ðLð ðLð ðLð 
óLðB
�cð 
 ð 
¨Sð 
°Tô 
r9   