Skip to content

Commit

Permalink
fix: Use the commit distance in the dev_branch as well (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP authored May 12, 2020
1 parent 3123cdc commit 9c9c325
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions spec/git-version-spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe GitVersion do

version = git.get_version

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

tmp.exec %(git checkout -b feature-branch)
tmp.exec %(touch file2.txt)
Expand Down Expand Up @@ -90,23 +90,23 @@ describe GitVersion do

version = git.get_version

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

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

hash = git.current_commit_hash

version = git.get_version

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

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

hash = git.current_commit_hash

version = git.get_version

version.should eq("2.0.0-SNAPSHOT.#{hash}")
version.should eq("2.0.0-SNAPSHOT.3.#{hash}")
ensure
tmp.cleanup
end
Expand Down Expand Up @@ -311,7 +311,7 @@ describe GitVersion do
tmp.exec %(git commit --no-gpg-sign --allow-empty -m "2")
hash = git.current_commit_hash
version = git.get_version
version.should eq("1.0.1-SNAPSHOT.#{hash}")
version.should eq("1.0.1-SNAPSHOT.1.#{hash}")

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

tmp.exec %(git checkout master)
tmp.exec %(git merge --no-gpg-sign --no-ff dev)
Expand Down Expand Up @@ -403,7 +403,7 @@ describe GitVersion do
version = git.get_version
hash = git.current_commit_hash
tmp.exec %(git tag "#{version}")
version.should eq("1.0.1-SNAPSHOT.#{hash}")
version.should eq("1.0.1-SNAPSHOT.1.#{hash}")

tmp.exec %(git checkout master)
tmp.exec %(git merge --no-gpg-sign --no-ff dev)
Expand Down
2 changes: 1 addition & 1 deletion src/git-version.cr
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module GitVersion
if cb == @release_branch
#
elsif cb == @dev_branch
prerelease = [DEV_BRANCH_SUFFIX, current_commit_hash()] of String | Int32
prerelease = [DEV_BRANCH_SUFFIX, commits_distance(latest_tagged_version), current_commit_hash()] of String | Int32
latest_version =
SemanticVersion.new(
latest_version.major,
Expand Down

0 comments on commit 9c9c325

Please sign in to comment.