@@ -36,7 +36,7 @@ def gh_pull_request(pr_num):
36
36
37
37
38
38
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' ])
40
40
41
41
42
42
def update_changelog (lines , cur_version_str , new_version_str ):
@@ -65,18 +65,28 @@ def process_git_log(git_log):
65
65
return lines
66
66
67
67
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 )
73
74
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 )
75
76
76
77
77
78
if __name__ == '__main__' :
78
79
# 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 )):
80
89
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 ])))
81
91
sys .exit (2 )
82
- main (sys . argv [ 1 ] )
92
+ main (new_ver , old_ver )
0 commit comments