<s> import os <EOL> import subprocess <EOL> from . . version import __version__ <EOL> def get_head ( repo_path ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> ref = open ( os . path . join ( repo_path , '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT:r>' ) . read ( ) . strip ( ) [ <NUM_LIT:5> : ] . split ( '<STR_LIT:/>' ) <EOL> branch = ref [ - <NUM_LIT:1> ] <EOL> commit = open ( os . path . join ( repo_path , '<STR_LIT>' , * ref ) , '<STR_LIT:r>' ) . read ( ) . strip ( ) [ : <NUM_LIT:7> ] <EOL> return branch , commit <EOL> except : <EOL> return None <EOL> def get_version ( repo_path ) : <EOL> try : <EOL> version = __version__ . split ( '<STR_LIT:.>' ) <EOL> major , minor , cn = [ int ( i ) for i in version ] <EOL> p = subprocess . Popen ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , os . path . join ( repo_path , '<STR_LIT>' ) , <EOL> '<STR_LIT>' , repo_path , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> stdout = subprocess . PIPE , stderr = subprocess . PIPE ) <EOL> raw , err = p . communicate ( ) <EOL> c_head = int ( raw . decode ( '<STR_LIT:ascii>' ) ) <EOL> q = subprocess . Popen ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , os . path . join ( repo_path , '<STR_LIT>' ) , <EOL> '<STR_LIT>' , repo_path , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> stdout = subprocess . PIPE , stderr = subprocess . PIPE ) <EOL> raw , err = q . communicate ( ) <EOL> c_master = int ( raw . decode ( '<STR_LIT:ascii>' ) ) <EOL> cc = c_head - c_master <EOL> assert cc <EOL> return '<STR_LIT>' % ( major , minor , cn + cc ) <EOL> except : <EOL> return __version__ </s>
