Skip to content

Commit 9c9c325

Browse files
authored
fix: Use the commit distance in the dev_branch as well (#31)
1 parent 3123cdc commit 9c9c325

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

spec/git-version-spec.cr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe GitVersion do
3636

3737
version = git.get_version
3838

39-
version.should eq("1.0.1-SNAPSHOT.#{hash}")
39+
version.should eq("1.0.1-SNAPSHOT.1.#{hash}")
4040

4141
tmp.exec %(git checkout -b feature-branch)
4242
tmp.exec %(touch file2.txt)
@@ -90,23 +90,23 @@ describe GitVersion do
9090

9191
version = git.get_version
9292

93-
version.should eq("2.0.0-SNAPSHOT.#{hash}")
93+
version.should eq("2.0.0-SNAPSHOT.1.#{hash}")
9494

9595
tmp.exec %(git commit --no-gpg-sign --allow-empty -m "breaking: XYZ")
9696

9797
hash = git.current_commit_hash
9898

9999
version = git.get_version
100100

101-
version.should eq("2.0.0-SNAPSHOT.#{hash}")
101+
version.should eq("2.0.0-SNAPSHOT.2.#{hash}")
102102

103103
tmp.exec %(git commit --no-gpg-sign --allow-empty -m "feature: XYZ")
104104

105105
hash = git.current_commit_hash
106106

107107
version = git.get_version
108108

109-
version.should eq("2.0.0-SNAPSHOT.#{hash}")
109+
version.should eq("2.0.0-SNAPSHOT.3.#{hash}")
110110
ensure
111111
tmp.cleanup
112112
end
@@ -311,7 +311,7 @@ describe GitVersion do
311311
tmp.exec %(git commit --no-gpg-sign --allow-empty -m "2")
312312
hash = git.current_commit_hash
313313
version = git.get_version
314-
version.should eq("1.0.1-SNAPSHOT.#{hash}")
314+
version.should eq("1.0.1-SNAPSHOT.1.#{hash}")
315315

316316
tmp.exec %(git checkout -b myfeature)
317317
tmp.exec %(git commit --no-gpg-sign --allow-empty -m "3")
@@ -375,7 +375,7 @@ describe GitVersion do
375375
version = git.get_version
376376
hash = git.current_commit_hash
377377
tmp.exec %(git tag "#{version}")
378-
version.should eq("2.0.0-SNAPSHOT.#{hash}")
378+
version.should eq("2.0.0-SNAPSHOT.1.#{hash}")
379379

380380
tmp.exec %(git checkout master)
381381
tmp.exec %(git merge --no-gpg-sign --no-ff dev)
@@ -403,7 +403,7 @@ describe GitVersion do
403403
version = git.get_version
404404
hash = git.current_commit_hash
405405
tmp.exec %(git tag "#{version}")
406-
version.should eq("1.0.1-SNAPSHOT.#{hash}")
406+
version.should eq("1.0.1-SNAPSHOT.1.#{hash}")
407407

408408
tmp.exec %(git checkout master)
409409
tmp.exec %(git merge --no-gpg-sign --no-ff dev)

src/git-version.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ module GitVersion
160160
if cb == @release_branch
161161
#
162162
elsif cb == @dev_branch
163-
prerelease = [DEV_BRANCH_SUFFIX, current_commit_hash()] of String | Int32
163+
prerelease = [DEV_BRANCH_SUFFIX, commits_distance(latest_tagged_version), current_commit_hash()] of String | Int32
164164
latest_version =
165165
SemanticVersion.new(
166166
latest_version.major,

0 commit comments

Comments
 (0)