@@ -38,8 +38,11 @@ def increment_patch(ver):
38
38
def command_output (cmd , cwd ):
39
39
return subprocess .check_output (cmd , cwd = cwd ).decode ("utf-8" ).strip ()
40
40
41
- def git_history_since (ver , repo_path ):
42
- return re .split (r"[\r\n]+" , command_output (["git" , "log" , "--oneline" , f"v{ ver } ..HEAD" ], cwd = repo_path ))
41
+ def git_last_tag (repo_path ):
42
+ return command_output (["git" , "describe" , "--abbrev=0" ], cwd = repo_path )
43
+
44
+ def git_history_since_last_tag (repo_path ):
45
+ return re .split (r"[\r\n]+" , command_output (["git" , "log" , "--oneline" , f"{ git_last_tag (repo_path )} ..HEAD" ], cwd = repo_path ))
43
46
44
47
def git_branch (repo_path ):
45
48
return command_output (["git" , "rev-parse" , "--abbrev-ref" , "HEAD" ], cwd = repo_path )
@@ -87,13 +90,13 @@ def main():
87
90
temp = tempfile .NamedTemporaryFile (delete = False )
88
91
temp_path = Path (temp .name ).absolute ()
89
92
90
- history = git_history_since ( previous_version , PROJECT_DIR )
93
+ history = git_history_since_last_tag ( PROJECT_DIR )
91
94
formatted_history = [f"# { commit } " for commit in history ]
92
95
initial_message = [
93
96
"" ,
94
97
"" ,
95
98
"# Please enter a changelog/release message." ,
96
- "# This is the history between {previous_version} and {new_version} :"
99
+ f "# This is the history since the last tag :"
97
100
] + formatted_history
98
101
99
102
with open (temp_path , "w" ) as temp_contents :
0 commit comments