|
|
|
@ -229,15 +229,6 @@ class GIT(object):
|
|
|
|
|
key = 'branch.%s.%s' % (branch, key)
|
|
|
|
|
GIT.SetConfig(cwd, key, value)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def IsWorkTreeDirty(cwd):
|
|
|
|
|
return GIT.Capture(['status', '-s'], cwd=cwd) != ''
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def GetEmail(cwd):
|
|
|
|
|
"""Retrieves the user email address if known."""
|
|
|
|
|
return GIT.GetConfig(cwd, 'user.email', '')
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def ShortBranchName(branch):
|
|
|
|
|
"""Converts a name like 'refs/heads/foo' to just 'foo'."""
|
|
|
|
@ -428,17 +419,6 @@ class GIT(object):
|
|
|
|
|
diff[i] = '--- %s' % diff[i + 1][4:]
|
|
|
|
|
return ''.join(diff)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def GetDifferentFiles(cwd, branch=None, branch_head='HEAD'):
|
|
|
|
|
"""Returns the list of modified files between two branches."""
|
|
|
|
|
if not branch:
|
|
|
|
|
branch = GIT.GetUpstreamBranch(cwd)
|
|
|
|
|
command = [
|
|
|
|
|
'-c', 'core.quotePath=false', 'diff', '--name-only',
|
|
|
|
|
branch + "..." + branch_head
|
|
|
|
|
]
|
|
|
|
|
return GIT.Capture(command, cwd=cwd).splitlines(False)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def GetAllFiles(cwd):
|
|
|
|
|
"""Returns the list of all files under revision control."""
|
|
|
|
@ -462,12 +442,6 @@ class GIT(object):
|
|
|
|
|
commit_hashes[record[3]] = record[1]
|
|
|
|
|
return commit_hashes
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def GetPatchName(cwd):
|
|
|
|
|
"""Constructs a name for this patch."""
|
|
|
|
|
short_sha = GIT.Capture(['rev-parse', '--short=4', 'HEAD'], cwd=cwd)
|
|
|
|
|
return "%s#%s" % (GIT.GetBranch(cwd), short_sha)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def GetCheckoutRoot(cwd):
|
|
|
|
|
"""Returns the top level directory of a git checkout as an absolute path.
|
|
|
|
@ -475,10 +449,6 @@ class GIT(object):
|
|
|
|
|
root = GIT.Capture(['rev-parse', '--show-cdup'], cwd=cwd)
|
|
|
|
|
return os.path.abspath(os.path.join(cwd, root))
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def GetGitDir(cwd):
|
|
|
|
|
return os.path.abspath(GIT.Capture(['rev-parse', '--git-dir'], cwd=cwd))
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def IsInsideWorkTree(cwd):
|
|
|
|
|
try:
|
|
|
|
|