2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-12 00:06:36 +00:00

[fix] version backward compatibility fix

This commit is contained in:
Anand Doshi 2016-06-09 18:54:41 +05:30
parent f08d7e2605
commit 2e02ec78a2

View File

@ -140,7 +140,7 @@ def get_current_version(app, bench='.'):
except AttributeError:
# backward compatibility
with open(os.path.join(repo_dir, 'setup.py')) as f:
return get_version_from_string(f.read())
return get_version_from_string(f.read(), field='version')
def get_upstream_version(app, branch=None, bench='.'):
repo_dir = get_repo_dir(app, bench=bench)
@ -206,8 +206,8 @@ def switch_to_v4(apps=None, bench='.', upgrade=False):
def switch_to_v5(apps=None, bench='.', upgrade=False):
switch_branch('v5.x.x', apps=apps, bench=bench, upgrade=upgrade)
def get_version_from_string(contents):
match = re.search(r"^(\s*%s\s*=\s*['\\\"])(.+?)(['\"])(?sm)" % '__version__',
def get_version_from_string(contents, field='__version__'):
match = re.search(r"^(\s*%s\s*=\s*['\\\"])(.+?)(['\"])(?sm)" % field,
contents)
return match.group(2)