Skip to content

Commit 510e87c

Browse files
committed
fix(gitversion): 🐛 correct version determination
1 parent 9fb75b6 commit 510e87c

3 files changed

Lines changed: 4 additions & 21 deletions

File tree

src/gitversion/_bump-changelog.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ if [ -n "$dry_run" ] || [ -z "$bump" ]; then
326326
fi
327327

328328
# Determine version and range using the bump-version script
329-
determined_version=$(bump-version $minimal ${bump_version_dry_run} "$version")
329+
determined_version=$(bump-version $minimal ${bump_version_dry_run} $version)
330330
version=$(echo "$determined_version" | awk '{print $2}')
331331
range=$(echo "$determined_version" | awk '{print $1}')
332332
if [ -n "$version" ] && [ -n "$range" ]; then

src/gitversion/_bump-version.sh

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ set -e
1212
# Parse command line arguments using zz_args helper
1313
eval $(
1414
zz_args "Bump version files utility" $0 "$@" <<- help
15-
- version version Version to set in files (optional - will use GitVersion if not provided)
1615
m minimal minimal Only bump workspace files if commit scope relates to workspace name
1716
r range range Git range to check for affected workspaces (required for minimal mode)
1817
d - dry_run Show what would be updated without making changes
18+
- version version Version to set in files (optional - will use GitVersion if not provided)
1919
help
2020
)
2121

@@ -24,23 +24,6 @@ cd "$(git rev-parse --show-toplevel)" > /dev/null
2424

2525
# ===== VERSION DETERMINATION FUNCTIONS =====
2626

27-
# Use GitVersion to determine the current semantic version
28-
# Returns the semantic version based on git history and conventional commits
29-
get_gitversion() {
30-
local gitversion_output
31-
if command -v dotnet-gitversion > /dev/null 2>&1; then
32-
gitversion_output=$(dotnet-gitversion -config .gitversion 2>/dev/null)
33-
if [ $? -eq 0 ]; then
34-
echo "$gitversion_output" | jq -r '.SemVer'
35-
return 0
36-
fi
37-
fi
38-
39-
# Fallback to basic version extraction if GitVersion fails
40-
zz_log w "GitVersion not available or failed, falling back to tag-based versioning"
41-
get_latest_tag | sed 's/^v//' || echo "0.1.0"
42-
}
43-
4427
# Get the latest semantic version tag from git history (fallback method)
4528
get_latest_tag() {
4629
git tag -l --sort=-version:refname | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+' | head -1
@@ -251,7 +234,7 @@ bump_version_files() {
251234

252235
# Determine version using GitVersion or user input
253236
if [ -z "$version" ]; then
254-
version=$(get_gitversion)
237+
version=$(gv -showvariable SemVer)
255238
zz_log s "GitVersion determined version: $version"
256239
else
257240
version=$(format_version "$version")

src/gitversion/_gv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22

33
# Call the GitVersion tool with the specified configuration
4-
/usr/local/bin/dotnet-gitversion -config ${1:-$(git rev-parse --show-toplevel)/.gitversion}
4+
/usr/local/bin/dotnet-gitversion -config ${1:-$(git rev-parse --show-toplevel)/.gitversion} $@

0 commit comments

Comments
 (0)