TaqiRaza512's picture
Initial commit
a103028
import subprocess
from .Common import *
from .Execute import *
def git_diff_word_count():
return len(subprocess.check_output(['git', 'diff']).decode('ascii').strip())
def git_version():
return subprocess.check_output(['git', 'describe', '--tags', '--always']).decode('ascii').strip()
def git_revision_branch():
return subprocess.check_output(['git', 'branch', '--show-current']).decode('ascii').strip()
def git_revision_hash(short = True):
return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
def IsInsideGitRepository():
return IsInsidePackage() == False
# def CheckOutOrUpdateRepo( module_path, dst_dir, module_name = None, checkout_tag = None, repo_type = "git" ):
# if repo_type == "git":
# if DirExists( dst_dir ):
# log.info("Updating " + dst_dir)
# ExecuteCommandInstantOutput( "git pull" )
# return False
# else:
# if module_name:
# log.info("Checking out " + module_name + " from " + module_path)
# else:
# log.info("Checking out from " + module_path)
# ExecuteCommandInstantOutput( "git clone " + module_path + " " + dst_dir )
# if checkout_tag:
# __old_dir = GetCurrentDir()
# ChangeDir(dst_dir)
# ExecuteCommandInstantOutput( "git checkout " + str(checkout_tag) )
# ChangeDir( __old_dir)
# return True
# else:
# log.fatal("Repo type " + repo_type + " not supported" )