@@ -19,7 +19,8 @@ describe GitVersion do
19
19
20
20
version = git.get_new_version
21
21
22
- version.should eq(" 1.0.1" )
22
+ # no commit since latest tag, expect no version bump
23
+ version.should eq(" 1.0.0" )
23
24
24
25
tmp.exec %( git checkout -b dev)
25
26
tmp.exec %( git commit --no-gpg-sign --allow-empty -m "2")
@@ -132,7 +133,8 @@ describe GitVersion do
132
133
133
134
version = git.get_new_version
134
135
135
- version.should eq(" 1.0.1" )
136
+ # no new commit in master, expect no version bump
137
+ version.should eq(" 1.0.0" )
136
138
137
139
tmp.exec %( git merge my-fancy.branch)
138
140
@@ -148,7 +150,8 @@ describe GitVersion do
148
150
149
151
version = git.get_new_version
150
152
151
- version.should eq(" 2.0.1" )
153
+ # no new commit in master, expect no version bump
154
+ version.should eq(" 2.0.0" )
152
155
153
156
tmp.exec %( git merge --ff-only my-fancy.branch2)
154
157
@@ -164,7 +167,8 @@ describe GitVersion do
164
167
165
168
version = git.get_new_version
166
169
167
- version.should eq(" 3.0.1" )
170
+ # no new commit in master, expect no version bump
171
+ version.should eq(" 3.0.0" )
168
172
169
173
tmp.exec %( git merge --no-gpg-sign --no-ff my-fancy.branch3)
170
174
@@ -737,6 +741,45 @@ describe GitVersion do
737
741
tmp.cleanup
738
742
end
739
743
end
744
+
745
+ it " should not bump version if no commit matches log-path filter" do
746
+ tmp = InTmp .new
747
+
748
+ begin
749
+ git = GitVersion ::Git .new(" dev" , " master" , " feature:" , " breaking:" , tmp.@tmpdir , " dir1-" , " dir1/" )
750
+
751
+ tmp.exec %( git init)
752
+ tmp.exec %( git checkout -b master)
753
+
754
+ # Create dir1 and tag dir1-1.0.0
755
+ base_dir = " dir1"
756
+ tmp.exec %( mkdir #{ base_dir } && touch #{ base_dir } /dummy_file)
757
+ tmp.exec %( git add #{ base_dir } /)
758
+ tmp.exec %( git commit --no-gpg-sign -m "feature: 1")
759
+ tmp.exec %( git tag "dir1-1.0.0")
760
+
761
+ # Create dir2 and tag dir2-1.0.0
762
+ base_dir = " dir2"
763
+ tmp.exec %( mkdir #{ base_dir } && touch #{ base_dir } /dummy_file)
764
+ tmp.exec %( git add #{ base_dir } /)
765
+ tmp.exec %( git commit --no-gpg-sign -m "feature: 2")
766
+ tmp.exec %( git tag "dir2-1.0.0")
767
+
768
+ # Commit feature in dir2
769
+ base_dir = " dir2"
770
+ tmp.exec %( mkdir -p #{ base_dir } && touch #{ base_dir } /dummy_file_2)
771
+ tmp.exec %( git add #{ base_dir } /)
772
+ tmp.exec %( git commit --no-gpg-sign -m "feature: 3")
773
+
774
+ # git-version should not bump version for dir1
775
+ version = git.get_new_version
776
+ hash = git.current_commit_hash
777
+ version.should eq(" dir1-1.0.0" )
778
+ ensure
779
+ tmp.cleanup
780
+ end
781
+ end
782
+
740
783
it " should truncate long branch names in tags" do
741
784
tmp = InTmp .new
742
785
@@ -750,7 +793,13 @@ describe GitVersion do
750
793
751
794
version = git.get_new_version
752
795
hash = git.current_commit_hash
753
- version.should eq(" 100.100.101-veryveryveryverylongbranchname.0.#{ hash } " )
796
+ version.should eq(" 100.100.100-veryveryveryverylongbranchname.0.#{ hash } " )
797
+
798
+ tmp.exec %( git commit -m "commit" --allow-empty)
799
+
800
+ version = git.get_new_version
801
+ hash = git.current_commit_hash
802
+ version.should eq(" 100.100.101-veryveryveryverylongbranchname.1.#{ hash } " )
754
803
ensure
755
804
tmp.cleanup
756
805
end
0 commit comments