mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-29 09:39:04 +00:00
Minor improvement of getRevisionNumber logic
This commit is contained in:
@@ -22,43 +22,39 @@ def getRevisionNumber():
|
||||
|
||||
retVal = None
|
||||
filePath = None
|
||||
_ = os.path.dirname(__file__)
|
||||
directory = os.path.dirname(__file__)
|
||||
|
||||
while True:
|
||||
filePath = os.path.join(_, ".git", "HEAD")
|
||||
if os.path.exists(filePath):
|
||||
candidate = os.path.join(directory, ".git", "HEAD")
|
||||
if os.path.exists(candidate):
|
||||
filePath = candidate
|
||||
break
|
||||
else:
|
||||
filePath = None
|
||||
if _ == os.path.dirname(_):
|
||||
break
|
||||
else:
|
||||
_ = os.path.dirname(_)
|
||||
|
||||
while True:
|
||||
if filePath and os.path.isfile(filePath):
|
||||
with openFile(filePath, "r") as f:
|
||||
content = getText(f.read())
|
||||
filePath = None
|
||||
|
||||
if content.startswith("ref: "):
|
||||
try:
|
||||
filePath = os.path.join(_, ".git", content.replace("ref: ", "")).strip()
|
||||
except UnicodeError:
|
||||
pass
|
||||
|
||||
if filePath is None:
|
||||
match = re.match(r"(?i)[0-9a-f]{32}", content)
|
||||
retVal = match.group(0) if match else None
|
||||
break
|
||||
else:
|
||||
parent = os.path.dirname(directory)
|
||||
if parent == directory:
|
||||
break
|
||||
directory = parent
|
||||
|
||||
if filePath:
|
||||
with openFile(filePath, "r") as f:
|
||||
content = getText(f.read()).strip()
|
||||
|
||||
if content.startswith("ref: "):
|
||||
ref_path = content.replace("ref: ", "").strip()
|
||||
filePath = os.path.join(directory, ".git", ref_path)
|
||||
|
||||
if os.path.exists(filePath):
|
||||
with openFile(filePath, "r") as f_ref:
|
||||
content = getText(f_ref.read()).strip()
|
||||
|
||||
match = re.match(r"(?i)[0-9a-f]{40}", content)
|
||||
retVal = match.group(0) if match else None
|
||||
|
||||
if not retVal:
|
||||
try:
|
||||
process = subprocess.Popen("git rev-parse --verify HEAD", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
process = subprocess.Popen(["git", "rev-parse", "--verify", "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, _ = process.communicate()
|
||||
match = re.search(r"(?i)[0-9a-f]{32}", getText(stdout or ""))
|
||||
match = re.search(r"(?i)[0-9a-f]{40}", getText(stdout or ""))
|
||||
retVal = match.group(0) if match else None
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -19,7 +19,7 @@ from lib.core.enums import OS
|
||||
from thirdparty import six
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.10.1.58"
|
||||
VERSION = "1.10.1.59"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
||||
Reference in New Issue
Block a user