diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-07-19 15:37:19 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-07-19 15:37:19 -0400 |
commit | 4b50326dbcafb876dacfcaeac13e4a50df345f4e (patch) | |
tree | b7a97aa3f80fa3ce5b9679d4455f03b076374147 /buildscripts/utils.py | |
parent | 671778afa957f14a78214b6c426237e899c2ed14 (diff) | |
download | mongo-4b50326dbcafb876dacfcaeac13e4a50df345f4e.tar.gz |
cleaning and error code stuff
Diffstat (limited to 'buildscripts/utils.py')
-rw-r--r-- | buildscripts/utils.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/buildscripts/utils.py b/buildscripts/utils.py index faf48b21d41..1ca2fdd345f 100644 --- a/buildscripts/utils.py +++ b/buildscripts/utils.py @@ -5,6 +5,47 @@ import time import os # various utilities that are handy +def getGitBranch(): + if not os.path.exists( ".git" ): + return None + + version = open( ".git/HEAD" ,'r' ).read().strip() + if not version.startswith( "ref: " ): + return version + version = version.split( "/" ) + version = version[len(version)-1] + return version + +def getGitBranchString( prefix="" , postfix="" ): + t = re.compile( '[/\\\]' ).split( os.getcwd() ) + if len(t) > 2 and t[len(t)-1] == "mongo": + par = t[len(t)-2] + m = re.compile( ".*_([vV]\d+\.\d+)$" ).match( par ) + if m is not None: + return prefix + m.group(1).lower() + postfix + if par.find("Nightly") > 0: + return "" + + + b = getGitBranch() + if b == None or b == "master": + return "" + return prefix + b + postfix + +def getGitVersion(): + if not os.path.exists( ".git" ): + return "nogitversion" + + version = open( ".git/HEAD" ,'r' ).read().strip() + if not version.startswith( "ref: " ): + return version + version = version[5:] + f = ".git/" + version + if not os.path.exists( f ): + return version + return open( f , 'r' ).read().strip() + + def execsys( args ): import subprocess if isinstance( args , str ): |