
    7jN                     "    d Z ddlmZ d ZddZy)z-Functions for working with QMK's submodules.
    )clic                  
   i } t        j                  g dd      }|j                  j                         D ]2  }|j	                  dd      \  }}|j                  d      s+|dd	| |<   4 t        j                  g d
d      }|j                  j                         D ]_  }|d   }|dd j	                         dd \  }}|| |   d<   |dk(  r	d| |   d<   7|dk(  r	d| |   d<   E|dk(  r	d| |   d<   St        d|z         t        j                  g d      }	|	j                  j                         D ]i  }
|
j	                  d      }|d   }t        |      dkD  r|d   nd| |   d<   t        |      dkD  r|d   nd| |   d<   t        |      dkD  r|d   nd| |   d<   k t        j                  g d      }|j                  j                         D ]2  }
|
j	                         }|d   }t        |      dkD  r|d   nd| |   d<   4 | S )a)  Returns a dictionary of submodules.

    Each entry is a dict of the form:

        {
            'name': 'submodule_name',
            'status': None/False/True,
            'githash': '<sha-1 hash for the submodule>'
            'shorthash': '<short hash for the submodule>'
            'describe': '<output of `git describe --tags`>'
            'last_log_message': 'log message'
            'last_log_timestamp': 'timestamp'
        }

    status is None when the submodule doesn't exist, False when it's out of date, and True when it's current
    )gitconfigz-fz.gitmodulesz-l   )timeout=   )maxsplitz.pathN)namestatus)r   	submoduler   r      githash-r   +F Tz;Unknown `git submodule status` sha-1 prefix character: "%s")r   r   -qforeachzggit --no-pager log --no-show-signature --pretty=format:"$sm_path%x01%h%x01%ad%x01%s%x0A" --date=iso -n1 	shorthashlast_log_timestamp   last_log_message)r   r   r   r   z%'echo $sm_path `git describe --tags`'describe)r   runstdout
splitlinessplitendswith
ValueErrorlen)
submodulesgitmodule_configlinekeyvaluegit_cmdr   r   r   submodule_logslog_linersubmodule_tagss                G/home/hanthebot/chat/keyboard/qmk_firmware/lib/python/qmk/submodules.pyr   r      sB   " JwwKUWX ''224 @ZZaZ0
U<< ).$ ?Ju@
 gg4bAG))+ ea!!"X^^-bq1+2
9i(S=.2Jy!(+s].3Jy!(+s].2Jy!(+Z]ccdde WW  n  oN"))446 ONN6"aD	58VaZQqTR
9k*>A!fqjadb
923<?FQJAaDB
901O WWmnN"))446 GNNaD	47FQJAaDB
9j)G
     Nc                    g d}g d}| Q|j                  d       |j                  d       t        j                  |d       t        j                  |d       yt        | t              rQ|j                  |        |j                  |        t        j                  |d       t        j                  |d       y| D ]8  }t        j                  g ||d       t        j                  g ||d       : y)z{Update the submodules.

        submodules
            A string containing a single submodule or a list of submodules.
    )r   r   sync)r   r   updatez--initNz--recursiveT)check)appendr   r   
isinstancestr)r$   git_sync_cmdgit_update_cmdr   s       r.   r2   r2   >   s     0L=NM*m,D)d+ j#&
+!!*-GGL-GGN$/ ( B	2,2	2$?4.4)4DABr/   )N)__doc__milcr   r   r2    r/   r.   <module>r<      s    5pBr/   