def srcstat(env):
if not env.workPath:
secho ( 'ERROR: No ipbb work area detected', fg='red' )
return
secho ( "Packages", fg='blue' )
lSrcs = env.getSources()
if not lSrcs:
return
lSrcTable = Texttable(max_width=0)
lSrcTable.set_deco(Texttable.HEADER | Texttable.BORDER)
lSrcTable.set_chars(['-', '|', '+', '-'])
lSrcTable.header(['name', 'kind', 'version'])
for lSrc in lSrcs:
lSrcDir = join(env.src, lSrc)
lKind, lBranch = "unknown", None
# Check if a git repository
if exists(join( lSrcDir, '.git')):
with DirSentry(lSrcDir) as _:
lKind = 'git'
try:
# lBranch = sh.git('symbolic-ref','--short', 'HEAD').strip()
lBranch = sh.git('symbolic-ref', 'HEAD').split('/')[-1].strip()
except sh.ErrorReturnCode_128:
lBranch = sh.git('rev-parse', '--short', 'HEAD').strip()+'...'
try:
sh.git('diff', '--no-ext-diff', '--quiet').strip()
except sh.ErrorReturnCode_1:
lBranch += '*'
try:
sh.git('diff', '--no-ext-diff', '--cached', '--quiet').strip()
except sh.ErrorReturnCode_1:
lBranch += '+'
elif exists(join( lSrcDir, '.svn')):
with DirSentry(lSrcDir) as _:
lKind = 'svn'
lSVNInfoRaw = sh.svn('info')
lSVNInfo = { lEntry[0]:lEntry[1].strip() for lEntry in ( lLine.split(':',1) for lLine in lSVNInfoRaw.split('\n') if lLine )}
lBranch = lSVNInfo['URL'].replace( lSVNInfo['Repository Root']+'/', '' )
lSVNStatus = sh.svn('status','-q')
if len(lSVNStatus):
lBranch += '*'
lSrcTable.add_row([lSrc, lKind, lBranch])
echo ( lSrcTable.draw() )
# ------------------------------------------------------------------------------
评论列表
文章目录