2019-07-25 21:31:00 +00:00
|
|
|
#!/usr/bin/env python
|
2019-09-12 18:03:27 +00:00
|
|
|
"""Compatibility tests between last released and the current version.
|
2019-07-25 21:31:00 +00:00
|
|
|
|
2019-09-12 18:03:27 +00:00
|
|
|
Usage: ./update_compatibility_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>]
|
|
|
|
Example: ./update_compatibility_version.py 3.7.1
|
|
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import print_function
|
2019-07-25 21:31:00 +00:00
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
if len(sys.argv) < 2 or len(sys.argv) > 3:
|
2019-09-12 18:03:27 +00:00
|
|
|
print("""
|
2019-07-25 21:31:00 +00:00
|
|
|
[ERROR] Please specify a version.
|
|
|
|
|
2019-09-12 18:03:27 +00:00
|
|
|
./update_compatibility_version.py.py <MAJOR>.<MINOR>.<MICRO> [<RC version>]
|
2019-07-25 21:31:00 +00:00
|
|
|
|
|
|
|
Example:
|
2019-09-12 18:03:27 +00:00
|
|
|
./update_compatibility_version.py.py 3.7.1 2
|
|
|
|
""")
|
2019-07-25 21:31:00 +00:00
|
|
|
exit(1)
|
|
|
|
|
|
|
|
NEW_VERSION = sys.argv[1]
|
|
|
|
NEW_VERSION_INFO = NEW_VERSION.split('.')
|
|
|
|
if len(NEW_VERSION_INFO) != 3:
|
2019-09-12 18:03:27 +00:00
|
|
|
print("""
|
2019-07-25 21:31:00 +00:00
|
|
|
[ERROR] Version must be in the format <MAJOR>.<MINOR>.<MICRO>
|
|
|
|
|
|
|
|
Example:
|
2019-09-12 18:03:27 +00:00
|
|
|
./update_compatibility_version.py.py 3.7.3
|
|
|
|
""")
|
2019-07-25 21:31:00 +00:00
|
|
|
exit(1)
|
|
|
|
|
|
|
|
if len(sys.argv) > 2:
|
|
|
|
RC_VERSION = int(sys.argv[2])
|
|
|
|
# Do not update compatibility versions for rc release
|
|
|
|
if RC_VERSION != 0:
|
|
|
|
exit(0)
|
|
|
|
|
2019-09-12 18:03:27 +00:00
|
|
|
|
2019-07-25 21:31:00 +00:00
|
|
|
def RewriteTextFile(filename, line_rewriter):
|
|
|
|
lines = open(filename, 'r').readlines()
|
|
|
|
updated_lines = []
|
|
|
|
for line in lines:
|
|
|
|
updated_lines.append(line_rewriter(line))
|
|
|
|
if lines == updated_lines:
|
2019-09-12 18:03:27 +00:00
|
|
|
print('%s was not updated. Please double check.' % filename)
|
2019-07-25 21:31:00 +00:00
|
|
|
f = open(filename, 'w')
|
|
|
|
f.write(''.join(updated_lines))
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
|
2019-09-12 18:03:27 +00:00
|
|
|
def ReplaceVersion(line):
|
|
|
|
return re.sub(r'LAST_RELEASED=.*$', 'LAST_RELEASED=%s' % NEW_VERSION, line)
|
2019-07-25 21:31:00 +00:00
|
|
|
|
2019-09-12 18:03:27 +00:00
|
|
|
RewriteTextFile('tests.sh', ReplaceVersion)
|