Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write out HEAD sha/date in the build.log for the sake of troubleshooting & diagnostics #229

Merged
merged 3 commits into from
Jan 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ def GetCommandOutput(command):
pass
return None

def GetGitHeadInfo(context):
"""Returns HEAD commit id and date."""
try:
with CurrentWorkingDirectory(context.mayaUsdSrcDir):
commitSha = subprocess.check_output('git rev-parse HEAD', shell = True).decode()
commitDate = subprocess.check_output('git show -s HEAD --format="%ad"', shell = True).decode()
return commitSha, commitDate
except Exception as exp:
PrintError("Failed to run git commands : {exp}".format(exp=exp))
sys.exit(1)

def GetXcodeDeveloperDirectory():
"""Returns the active developer directory as reported by 'xcode-select -p'.
Returns None if none is set."""
Expand Down Expand Up @@ -109,7 +120,12 @@ def Run(context, cmd):
PrintInfo('Running "{cmd}"'.format(cmd=cmd))

with open(context.logFileLocation, "a") as logfile:
logfile.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M"))
logfile.write("#####################################################################################" + "\n")
logfile.write("log date: " + datetime.datetime.now().strftime("%Y-%m-%d %H:%M") + "\n")
commitID,commitData = GetGitHeadInfo(context)
logfile.write("commit sha: " + commitID)
logfile.write("commit date: " + commitData)
logfile.write("#####################################################################################" + "\n")
logfile.write("\n")
logfile.write(cmd)
logfile.write("\n")
Expand Down