Skip to content

Commit

Permalink
stabilize git commit id fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
kaazoo committed Oct 17, 2010
1 parent 5d383b6 commit 94e828e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ def copy_with_clean(src_files,dest_files,dest_path,env):

def get_git_commit():
try:
gitlog = subprocess.Popen(["git", "show", "--abbrev-commit"], stdout=subprocess.PIPE)
gitlog = subprocess.Popen(["git", "log", "--oneline", "-1"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
except OSError:
commit_string = ""
else:
if gitlog.wait() != 0:
output = gitlog.communicate()[0]
if gitlog.returncode > 0:
commit_string = ""
print("Not a Git repository. Can't fetch commit id.")
else:
commit_string = gitlog.communicate()[0].split("\n")[0].split(" ")[1]
commit_string = output.split(" ")[0]
print("Current Git commit id is: "+commit_string)
return commit_string

Expand Down

0 comments on commit 94e828e

Please sign in to comment.