o
    ?@iW1                  ,   @   sr  d dl Z d dlZd dlmZ d dlmZmZ d dlmZm	Z	m
Z
mZmZmZ dgddddd	d
gddddd	dgddddejgdgdddddgdddddgedddd e
D ddgdd d!gd"d d#gd$d eD d%d&d'gdd(d)d*d	d+gdd,d)d-d	d.gdd/d)d0d	d1gd2d d3gdd4d)d5d	d6gdd7d)d8d	ejejgd9gdd:d)d;d<d=gd>ed?d@dAgdBedCd@dDgdEedFd@ejgdGgdHdIejgdJgdKdLdMgZdNdOdPdQejjdRedSejjdTedSejjdUedSejjdVedSejjdWedSejjdXedSejjdYedSejjdZedSid[d\g d]d^d_d`d#gdad eD ejjdbdcgdSddd[Z	d}deedfee j dQee dge jfdhdiZdge jfdjdkZ d~dge j!fdldmZ"dnee dgee fdodpZ#dQedqedee$ de$dree dsee d(e$dted4e$d7e$de$duee d:e$d/e$dvee dwee de$d>ee dBee dEee d,e$dgdf,dxdyZ%ddzd{Z&e'd|kre&  dS dS )    N)Path)MappingOptional)check_versionVersionPatternStyleVcsVERSION_SOURCE_PATTERNz
--metadata
store_truemetadataz6Always include metadata. Ignored when --format is used)triggersactiondestdefaulthelpz--no-metadatastore_falsez5Never include metadata. Ignored when --format is usedz--dirtydirtyz?Include dirty flag if applicable. Ignored when --format is used)r   r   r   r   z--ignore-untrackedignore_untrackedzGIgnore untracked files when determining whether the repository is dirty)vcsr   r   r   r   z--tagged-metadatatagged_metadatazDInclude tagged metadata if applicable. Ignored when --format is usedz	--patterna  Regular expression matched against the version source. This must contain one capture group named `base` corresponding to the release segment of the source. Optionally, it may contain another two groups named `stage` and `revision` corresponding to a prerelease type (such as 'alpha' or 'rc') and number (such as in 'alpha-2' or 'rc3'). It may also contain a group named `tagged_metadata` corresponding to extra metadata after the main part of the version (typically after a plus sign). There may also be a group named `epoch` for the PEP 440 concept. If the `base` group is not present, then instead this will be interpreted as a named preset, which may be one of the following: {}, c                 C   s   g | ]}d  |jqS )z`{}`)formatvalue.0x r   N/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/dunamai/__main__.py
<listcomp>:   s    r   )r   r   r   z--pattern-prefixz3Insert this after the pattern's start anchor (`^`).)r   r   z--formatzCustom output format. Available substitutions: {base}, {stage}, {revision}, {distance}, {commit}, {dirty}, {tagged_metadata}, {epoch}, {branch}, {branch_escaped}, {timestamp}, {major}, {minor}, {patch}z--stylec                 C      g | ]}|j qS r   r   r   r   r   r   r   K       zPreconfigured output format. Will default to PEP 440 if not set and no custom format given. If you specify both a style and a custom format, then the format will be validated against the style's rules)r   choicesr   z--latest-tag
latest_tagFzKOnly inspect the latest tag on the latest tagged commit for a pattern matchz--highest-taghighest_tagzVOnly inspect the numerically highest tag across all tagged commits for a pattern matchz--strictstrictzYElevate warnings to errors. When there are no tags, fail instead of falling back to 0.0.0z--pathz:Directory to inspect, if not the current working directoryz--debugdebugz<Display additional information on stderr for troubleshootingz--bumpbumpzIncrement the last part of the version `base` by 1, unless the `stage` is set, in which case increment the `revision` by 1 or set it to a default of 2 if there was no `revision` Does nothing when on a commit with a version tag.z--full-commitfull_commitz2Get the full commit hash instead of the short form)r   r   r   r   r   r   z--commit-lengthcommit_lengthz?Use this many characters from the start of the full commit hash)r   r   typer   z--commit-prefixcommit_prefixz+Add this prefix when serializing commit IDsz--escape-withescape_withzbWhen escaping, replace with this substitution. The default is simply to remove invalid characters.z--tag-branchzBBranch on which to find tags, if different than the current branch)r   r   r   z	--tag-dirtagsz%Location of tags relative to the root)r   r   r   r   zGenerate dynamic versionscommandz&Generate version from a particular VCSr   z&Generate version from any detected VCS)descriptionargszGenerate version from GitzGenerate version from MercurialzGenerate version from Darcsz Generate version from SubversionzGenerate version from BazaarzGenerate version from FossilzGenerate version from Pijul)r0   sub_destsubz'Check if a version is valid for a styleversionz!Version to check; may be piped in?)r   r   r   nargsc                 C   r    r   r!   r   r   r   r   r      r"   zStyle against which to check)r   r#   r   r   )fromcheckspecparserreturnc           
   	   C   s  |d u rt j| d t jd}d| v rS| d D ]<}|d }d|v r=|g |d tjvr,q|dddd	 |d D 7 }|d
 }|j|d|idd | D  qd| v r|j	| d d}d|_
| d  D ]$\}}|j||d|dt jd}	t||	| d dkrt|nd  qh|S )Nr0   )r0   formatter_classr1   r   r   z (only: {})r   c                 S   r    r   )namer   r   r   r   r      r"   z build_parser.<locals>.<listcomp>r   c                 S   s   i | ]\}}|d vr||qS ))r   r   r   r   )r   kvr   r   r   
<dictcomp>   s    z build_parser.<locals>.<dictcomp>r3   r2   )r   T)r0   r   r<   )argparseArgumentParserArgumentDefaultsHelpFormatterr	   Anyr   joinadd_argumentitemsadd_subparsersrequired
add_parsergetbuild_parser)
r9   r:   r   argr   r   
subparsersr=   sub_spec	subparserr   r   r   rL      s>   
""rL   c                   C   s   t tS N)rL   cli_specr   r   r   r   
get_parser  s   rS   c                 C   s   t  | S rQ   )rS   
parse_args)argvr   r   r   rT     s   rT   r   c                 C   s(   | d ur| S t j st j  S d S rQ   )sysstdinisattyreadlinestripr!   r   r   r   
from_stdin  s
   
r[   patternr   styletag_dir
tag_branchpathpattern_prefixc                 C   s   t | |||||||||||}|jD ]}td| tjd qt||||||	|
|| |rJtd|j	tjd td|j
tjd d S d S )NzWarning: {}filez# Matched tag: {}z# Newer unmatched tags: {})r   from_vcsconcernsprintr   messagerV   stderr	serialize_matched_tag_newer_unmatched_tags)r   r\   r   r   r   r]   r$   r^   r'   r(   r   r_   r)   r&   r`   ra   r   r*   r,   r-   r%   r4   concernr   r   r   rd     s*   
rd   c            
      C   sZ  t  } z| jdkrnt| dd}t| dd }t| dd}t| dd}t| dd }t| d	d }t| d
d }tt| j| j| j| j| j	| j
rHt| j
nd | j|| j| j| j||| j| jd ur`t| jnd | j||||| j W d S | jdkrt| j}|d u rtdt|t| j
 W d S W d S  ty }	 zt|	tjd td W Y d }	~	d S d }	~	ww )Nr7   r^   r.   r_   r)   Fr   r*   r,   r-   r8   zA version must be specifiedrb      )rT   r/   getattrrd   r	   r   r\   r   r   r   r]   r   r$   r'   r(   r   r&   r`   r   ra   r%   r[   r4   
ValueErrorr   	Exceptionrf   rV   rh   exit)
r1   r^   r_   r)   r   r*   r,   r-   r4   er   r   r   mainI  sX   



rs   __main__)NNrQ   )r;   N)(rA   rV   pathlibr   typingr   r   dunamair   r   r   r   r	   r
   Gitr   rE   	Mercurialintstr
Subversioncommon_sub_argsrD   r   DarcsBazaarFossilPijulPep440rR   rB   rL   rS   	NamespacerT   r[   boolrd   rs   __name__r   r   r   r   <module>   s    

	  '@
#
	


0
,
