Ë
    €Ï¾  ã                   ó   — d 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  e	j"                  e	j$                  j&                  «      e	j(                   G d„ de	j*                  «      «       «       Z e	j"                  e	j$                  j.                  e	j$                  j0                  «       G d„ de«      «       Zy)z+Clone Google Cloud Platform git repository.é    )Úabsolute_import)Údivision)Úunicode_literals)Úgit)Ú
sourcerepo)Úbase)Ú
exceptions)Úlog)Ústorec                   ó<   — e Zd ZdZdddœZed„ «       Zd„ Zd„ Zd„ Z	y	)
ÚCloneGAz Clone a cloud source repository.aZ          This command clones a git repository from the currently active
        Google Cloud project into the specified directory or into the current
        directory if no target directory is specified.

        Each Google Cloud project can have zero or more git repositories
        associated with it. To see the available repositories, run:

          $ {parent_command} list

        The clone operation configures the local clone to use your gcloud
        credentials to authenticate future git operations. This command emits a
        warning if the cloud source repository is a mirror.
      a
        The example commands below show a sample workflow.

        $ gcloud init

        $ {command} REPOSITORY_NAME DIRECTORY_NAME

        $ cd DIRECTORY_NAME
          ... create/edit files and create one or more commits ...

        $ git push origin main
      )ÚDESCRIPTIONÚEXAMPLESc                 ó~   — | j                  ddd¬«       | j                  ddd¬«       | j                  d	d
dd¬«       y )Nz	--dry-runÚ
store_truezZIf provided, prints the command that would be run to standard out instead of executing it.©ÚactionÚhelpÚsrcÚREPOSITORY_NAMEzName of the repository.)Úmetavarr   ÚdstÚDIRECTORY_NAMEÚ?zDDirectory name for the cloned repo. Defaults to the repository name.)r   Únargsr   )Úadd_argument©Úparsers    ú!lib/surface/source/repos/clone.pyÚArgszCloneGA.Args?   s`   € à
×ÑØØð-ð ô /ð
 ×ÑØÐ(Ð/Hð ô Jà
×ÑØØ Øðð	 õ ó    c                  ó   — y)zBAlways false because --use-full-gcloud-path argument is not in GA.F© ©ÚselfÚargss     r   ÚUseFullGcloudPathzCloneGA.UseFullGcloudPathO   s   € àr!   c                 óV   — dj                  |||¬«      }t        j                  |«       y)z/Prints a warning if the repository is a mirror.z§Repository "{repo}" in project "{prj}" is a mirror. Pushing to this clone will have no effect.  Instead, clone the mirrored repository directly with 
$ git clone {url}©ÚrepoÚprjÚurlN)Úformatr
   Úwarning©r%   Úprojectr*   Ú
mirror_urlÚmessages        r   ÚActionIfMirrorzCloneGA.ActionIfMirrorS   s,   € ð÷ ‘v 4¨W¸*vÓEð ô ‡KKÕr!   c                 ó  — t        j                  d¬«       t        j                  |j                  «      }t        j
                  «       }|j                  |«      }t        |d«      rJ|j                  r>|j                  j                  }| j                  |j                  |j                  |¬«       t        j                  |j                  |j                  |j                  ¬«      }|j                  |j                  xs |j                  |j                   | j#                  |«      ¬«      }|rS|j                   sFt$        j&                  j)                  dj+                  |j                  ||j                  ¬«      «       y	y	y	)
zÀClone a GCP repository to the current directory.

    Args:
      args: argparse.Namespace, the arguments this command is run with.

    Returns:
      The path to the new git repository.
    T)Úuse_google_authÚmirrorConfig)r0   r*   r1   )Úuri)Údestination_pathÚdry_runÚ	full_pathz<Project [{prj}] repository [{repo}] was cloned to [{path}].
)r+   Úpathr*   N)Úc_storeÚLoadr   Ú	ParseRepor   ÚSourceÚGetRepoÚhasattrr6   r,   r3   Ú
projectsIdr   ÚGitÚCloner   r9   r'   r
   ÚstatusÚwriter-   )r%   r&   ÚresÚsource_handlerr*   r1   Ú
git_helperr;   s           r   ÚRunzCloneGA.Run[   s+  € ô ‡LL Õ&ä
×
Ñ
˜tŸx™xÓ
(€CÜ×&Ñ&Ó(€Nà×!Ñ! #Ó&€DÜˆt^Ô$¨×):Ò):Ø×$Ñ$×(Ñ(€jØ
×ÑØ—.‘. t§x¡x¸Jð ô Hô —‘˜Ÿ™¨¯©°t·x±xÔ@€JØ×ÑØŸ™Ò- T§X¡XØ—‘Ø×(Ñ(¨Ó.ð ó 0€Dñ D—L’LÜ	‡jj×Ñð (ß(.©Ø"Ÿ~™~°D¸t¿x¹xð )/ó )IõJð !€tr!   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údetailed_helpÚstaticmethodr    r'   r3   rJ   r#   r!   r   r   r      s<   „ ñ )ð
ð
ñ€-ð: ñó ðòòóJr!   r   c                   ó,   — e Zd ZdZed„ «       Zd„ Zd„ Zy)Ú
CloneAlphaa¢  Clone a cloud source repository.

  This command clones a git repository for the currently active
  Google Cloud Platform project into the specified directory or into
  the current directory if no target directory is specified.  This command
  gives an error if the cloud source repository is a mirror.

  The clone operation configures the local clone to use your gcloud
  credentials to authenticate future git operations.

  ## EXAMPLES

  The example commands below show a sample workflow.

    $ gcloud init
    $ {command} REPOSITORY_NAME DIRECTORY_NAME
    $ cd DIRECTORY_NAME
    ... create/edit files and create one or more commits ...
    $ git push origin main
  c                 óV   — t         j                  | «       | j                  ddd¬«       y )Nz--use-full-gcloud-pathr   z·If provided, use the full gcloud path for the git credential.helper. Using the full path means that gcloud does not need to be in the path for future git operations on the repository.r   )r   r    r   r   s    r   r    zCloneAlpha.Args’   s.   € ä‡LLÔØ
×ÑØ Øð
Að	 õ Cr!   c                 ó   — |j                   S )z?Use value of --use-full-gcloud-path argument in beta and alpha.)Úuse_full_gcloud_pathr$   s     r   r'   zCloneAlpha.UseFullGcloudPath   s   € à×$Ñ$Ð$r!   c                 óV   — dj                  |||¬«      }t        j                  d|«      ‚)z2Raises an exception if the repository is a mirror.zrRepository "{repo}" in project "{prj}" is a mirror. Clone the mirrored repository directly with 
$ git clone {url}r)   r   )r-   Úc_excÚInvalidArgumentExceptionr/   s        r   r3   zCloneAlpha.ActionIfMirror¡   s2   € ðç‘v 4¨W¸*vÓEð ô ×
(Ñ
(Ð):¸GÓ
DÐDr!   N)rK   rL   rM   rN   rP   r    r'   r3   r#   r!   r   rR   rR   {   s(   „ ñð* ñCó ðCò%óEr!   rR   N)rN   Ú
__future__r   r   r   Úgooglecloudsdk.api_lib.sourcer   r   Úgooglecloudsdk.callioper   r	   rW   Úgooglecloudsdk.corer
   Úgooglecloudsdk.core.credentialsr   r<   ÚReleaseTracksÚReleaseTrackÚGAÚDefaultUniverseOnlyÚCommandr   ÚBETAÚALPHArR   r#   r!   r   Ú<module>re      s¸   ðñ 2å &Ý Ý 'å -Ý 4Ý (Ý 7Ý #Ý <ð €×ÑD×%Ñ%×(Ñ(Ó)Ø×ÑôYJˆdl‰ló YJó ó *ðYJðx €×ÑD×%Ñ%×*Ñ*¨D×,=Ñ,=×,CÑ,CÓDô*Eó *Eó Eñ*Er!   