
                         D   d Z ddlmZ ddlmZ ddlm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Ze
j$                   e
j&                  e
j(                  j*                  e
j(                  j,                         G d de
j.                                      Zy)zThe gen_repo_info_file command.    )absolute_import)division)unicode_literalsN)context_util)base)
exceptions)log)filesc                   d    e Zd ZdZdj	                  ej                        ddZed        Z	d Z
y)	GenRepoInfoFilea2  [DEPRECATED] Saves repository information in a file.

  DEPRECATED, use `gcloud beta debug source gen-repo-info-file` instead.  The
  generated file is an opaque blob representing which source revision the
  application was built at, and which Google-hosted repository this revision
  will be pushed to.
  a            DEPRECATED, use `gcloud beta debug source gen-repo-info-file`
          instead.

          This command generates a {name} file, containing information on the
          source revision and remote repository associated with the given
          source directory.

          {name} contains information on the remote repository: the associated
          Cloud Repository if there is one, or the remote Git repository if
          there is no Cloud Repository.
          namez          To generate repository information file for your app,
          from your source directory run:

            $ {command}
          )DESCRIPTIONEXAMPLESc                     | j                  ddd       | j                  ddj                  t        j                               | j                  d	d
d       y )Nz--source-directory.z?The path to directory containing the source code for the build.)defaulthelpz--output-filez(Deprecated; use --output-directory instead.) Specifies the full name of the output file to contain a single source context.  The file name must be "{name}" in order to work with cloud diagnostic tools.r   )r   z--output-directory zThe directory in which to create the source context file. Defaults to the current directory, or the directory containing --output-file if that option is provided with a file name that includes a directory path.)add_argumentformatr   CONTEXT_FILENAME)parsers    %lib/surface/app/gen_repo_info_file.pyArgszGenRepoInfoFile.ArgsA   sx    
N  P
 9 ;A&!22 ;A ;4  5 )	  +    c                    t         j                  rt        j                  d      t	        j
                  d       t        j                  |j                        }|j                  rKt	        j
                  d       t        j                  j                  |j                        }|j                  }nd}t        j                  }|s;|j                  r-|j                  }t        j                  j                  ||      }nd}t        j                   |      }t#        j$                  |       t#        j&                  |t)        j*                  |dd             y )	Nz&This command does not support python3.z]This command is deprecated. Please use `gcloud beta source debug gen-repo-info-file` instead.z@The --output-file option is deprecated and will soon be removed.r   r      T)indent	sort_keys)sixPY3r   NotSupportedPy3Exceptionr	   warningr   CalculateExtendedSourceContextssource_directoryoutput_fileospathdirnamer   output_directoryjoinBestSourceContextr
   MakeDirWriteFileContentsjsondumps)selfargscontextsr+   r'   best_contexts         r   RunzGenRepoInfoFile.RunY   s   
ww//
24 4 KK I J;;H 	kk
LN)9)9:$$k 11k			00ggll#3[A11(;L	MM"#	TZZQ$GIr   N)__name__
__module____qualname____doc__r   r   r   detailed_helpstaticmethodr   r6    r   r   r   r   !   sF     f,77f8-* + +.Ir   r   )r:   
__future__r   r   r   r0   r(   googlecloudsdk.appengine.toolsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.appr   googlecloudsdk.corer	   googlecloudsdk.core.utilr
   r!   HiddenReleaseTracksReleaseTrackGABETACommandr   r=   r   r   <module>rJ      s     & &  '  	 7 ( 5 # * 
 D%%(($*;*;*@*@ATIdll TI B TIr   