2011-02-07 02:25:55 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
2012-01-11 18:59:46 +04:00
|
|
|
Copyright (c) 2006-2012 sqlmap developers (http://www.sqlmap.org/)
|
2011-02-07 02:25:55 +03:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
|
|
|
from subprocess import PIPE
|
|
|
|
from subprocess import Popen as execute
|
|
|
|
|
|
|
|
def getRevisionNumber():
|
|
|
|
retVal = None
|
2012-07-02 15:01:20 +04:00
|
|
|
filePath = None
|
|
|
|
|
|
|
|
_ = os.path.dirname(__file__)
|
|
|
|
while True:
|
|
|
|
filePath = os.path.join(_, ".git/refs/heads/master").replace('/', os.path.sep)
|
|
|
|
if os.path.exists(filePath):
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
filePath = None
|
|
|
|
if _ == os.path.dirname(_):
|
|
|
|
break
|
2011-03-08 00:54:30 +03:00
|
|
|
else:
|
2012-07-02 15:01:20 +04:00
|
|
|
_ = os.path.dirname(_)
|
|
|
|
if filePath:
|
|
|
|
with open(filePath, "r") as f:
|
|
|
|
match = re.match(r"(?i)[0-9a-f]{32}", f.read())
|
|
|
|
retVal = match.group(0) if match else None
|
2011-03-08 00:54:30 +03:00
|
|
|
|
2012-07-02 15:01:20 +04:00
|
|
|
if not retVal:
|
|
|
|
process = execute("git rev-parse --verify HEAD", shell=True, stdout=PIPE, stderr=PIPE)
|
|
|
|
stdout, _ = process.communicate()
|
|
|
|
match = re.search(r"(?i)[0-9a-f]{32}", stdout or "")
|
|
|
|
retVal = match.group(0) if match else None
|
2011-02-07 02:25:55 +03:00
|
|
|
|
2012-07-02 15:01:20 +04:00
|
|
|
return retVal[:10] if retVal else None
|