Skip to content

Commit a4d95d9

Browse files
fix: correctly get the versioning segments and increment
1 parent aec9c39 commit a4d95d9

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

bin/git-make-release

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# Prompt for the version number
44
prompt_for_version() {
@@ -8,19 +8,26 @@ prompt_for_version() {
88

99
# Increment version number
1010
increment_version() {
11-
local IFS='.'
12-
read -ar version_parts <<< "$1"
13-
# Increment the minor version and reset patch version
11+
# Split the version string into parts using read -a
12+
IFS='.'
13+
read -ra version_parts <<< "$1"
14+
15+
# Ensure that we have exactly three parts for major, minor, and patch versions
16+
if [ ${#version_parts[@]} -ne 3 ]; then
17+
echo "Error: Invalid version format '$1'. Expected format 'Major.Minor.Patch'." >&2
18+
return 1 # Exit the function with an error status
19+
fi
20+
21+
# Increment the minor version and reset the patch version to 0
1422
local next_version="${version_parts[0]}.$((version_parts[1] + 1)).0"
1523

16-
# Prompt for the version number, using the next version as the default
17-
read -rp "Enter the version number (default: $next_version): " version
18-
echo "${version:-$next_version}" # Return the entered version number or the default if none was entered
24+
# Call prompt_for_version, using the next version as the default
25+
prompt_for_version "$next_version"
1926
}
2027

2128
# Get the latest version tag
2229
get_latest_version() {
23-
git describe --tags "$(git rev-list --tags --max-count=1)"
30+
git describe --tags "$(git rev-list --tags --max-count=1)" 2>/dev/null || echo "v0.0.0"
2431
}
2532

2633
# Prepend the tickets to the CHANGELOG.md

0 commit comments

Comments
 (0)