Skip to content
This repository was archived by the owner on Dec 29, 2020. It is now read-only.

Commit 1452c0c

Browse files
author
Vincent Rivellino
committed
Specify old version to release prep script
1 parent fe7786e commit 1452c0c

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

scripts/prepare-for-release.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def gh_pull_request(pr_num):
3636

3737

3838
def produce_iam_diff(cur_version_str):
39-
return subprocess.check_output(['git', 'diff', '{}...HEAD'.format(cur_version_str.split('-')[0]), 'iam-global.yml'])
39+
return subprocess.check_output(['git', 'diff', '{}...HEAD'.format(cur_version_str), 'iam-global.yml'])
4040

4141

4242
def update_changelog(lines, cur_version_str, new_version_str):
@@ -65,18 +65,28 @@ def process_git_log(git_log):
6565
return lines
6666

6767

68-
def main(new_version_str):
69-
version_str = subprocess.check_output(['git', 'describe', '--tags']).split('-')[0]
70-
if not re.match(r'^v\d+[.]\d+[.]\d+', version_str):
71-
print('Warning: "git describe --tags" might have a wonky output: {}'.format(version_str))
72-
git_log = git_log_since_last_release(version_str)
68+
def main(new_version_str, cur_version_str=None):
69+
if cur_version_str is None:
70+
cur_version_str = subprocess.check_output(['git', 'describe', '--tags']).split('-')[0]
71+
if not re.match(r'^v\d+[.]\d+[.]\d+', cur_version_str):
72+
print('Warning: "git describe --tags" might have a wonky output: {}'.format(cur_version_str))
73+
git_log = git_log_since_last_release(cur_version_str)
7374
changes = process_git_log(git_log)
74-
update_changelog(changes, version_str, new_version_str)
75+
update_changelog(changes, cur_version_str, new_version_str)
7576

7677

7778
if __name__ == '__main__':
7879
# match v1.2.3 or v1.2.3-beta1
79-
if len(sys.argv) != 2 or not re.match(r'^v\d+[.]\d+[.]\d+(-\w+)?$', sys.argv[1]):
80+
old_ver = None
81+
new_ver = None
82+
if len(sys.argv) == 2:
83+
new_ver = sys.argv[1]
84+
elif len(sys.argv) == 3:
85+
old_ver = sys.argv[1]
86+
new_ver = sys.argv[2]
87+
if not new_ver or not re.match(r'^v\d+[.]\d+[.]\d+(-\w+)?$', new_ver) \
88+
or (old_ver and not re.match(r'^v\d+[.]\d+[.]\d+(-\w+)?$', old_ver)):
8089
print('Usage: {script} NEW_VERSION'.format(script=os.path.basename(sys.argv[0])))
90+
print('Usage: {script} OLD_VERSION NEW_VERSION'.format(script=os.path.basename(sys.argv[0])))
8191
sys.exit(2)
82-
main(sys.argv[1])
92+
main(new_ver, old_ver)

0 commit comments

Comments
 (0)