Auto-detect the current git branch before submitting back to perforce.
Signed-off-by: Simon Hausmann <simon@lst.de>
This commit is contained in:
parent
4d9e5fcea6
commit
d566209e7f
@ -33,6 +33,10 @@ def p4Cmd(cmd):
|
|||||||
result.update(entry)
|
result.update(entry)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
def die(msg):
|
||||||
|
sys.stderr.write(msg + "\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], "", [ "continue", "git-dir=", "origin=", "reset", "master=",
|
opts, args = getopt.getopt(sys.argv[1:], "", [ "continue", "git-dir=", "origin=", "reset", "master=",
|
||||||
"submit-log-subst=", "log-substitutions=", "interactive",
|
"submit-log-subst=", "log-substitutions=", "interactive",
|
||||||
@ -46,7 +50,7 @@ def p4Cmd(cmd):
|
|||||||
logSubstitutions["\tDetails:"] = "\tDetails: %log%"
|
logSubstitutions["\tDetails:"] = "\tDetails: %log%"
|
||||||
gitdir = os.environ.get("GIT_DIR", "")
|
gitdir = os.environ.get("GIT_DIR", "")
|
||||||
origin = "origin"
|
origin = "origin"
|
||||||
master = "master"
|
master = ""
|
||||||
firstTime = True
|
firstTime = True
|
||||||
reset = False
|
reset = False
|
||||||
interactive = False
|
interactive = False
|
||||||
@ -88,9 +92,12 @@ def p4Cmd(cmd):
|
|||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
origin = args[0]
|
origin = args[0]
|
||||||
|
|
||||||
def die(msg):
|
if len(master) == 0:
|
||||||
sys.stderr.write(msg + "\n")
|
sys.stdout.write("Auto-detecting current branch: ")
|
||||||
sys.exit(1)
|
master = os.popen("git-name-rev HEAD").read().split(" ")[1][:-1]
|
||||||
|
if len(master) == 0 or not os.path.exists("%s/refs/heads/%s" % (gitdir, master)):
|
||||||
|
die("\nFailed to detect current branch! Aborting!");
|
||||||
|
sys.stdout.write("%s\n" % master)
|
||||||
|
|
||||||
def system(cmd):
|
def system(cmd):
|
||||||
if os.system(cmd) != 0:
|
if os.system(cmd) != 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user