Skip to content

Commit cf439a1

Browse files
committed
Fetch Git history based on last tag instead of version in bump_version
1 parent 9aa32d2 commit cf439a1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/bump_version.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ def increment_patch(ver):
3838
def command_output(cmd, cwd):
3939
return subprocess.check_output(cmd, cwd=cwd).decode("utf-8").strip()
4040

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))
4346

4447
def git_branch(repo_path):
4548
return command_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=repo_path)
@@ -87,13 +90,13 @@ def main():
8790
temp = tempfile.NamedTemporaryFile(delete=False)
8891
temp_path = Path(temp.name).absolute()
8992

90-
history = git_history_since(previous_version, PROJECT_DIR)
93+
history = git_history_since_last_tag(PROJECT_DIR)
9194
formatted_history = [f"# {commit}" for commit in history]
9295
initial_message = [
9396
"",
9497
"",
9598
"# 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:"
97100
] + formatted_history
98101

99102
with open(temp_path, "w") as temp_contents:

0 commit comments

Comments
 (0)