@@ -9,7 +9,13 @@ import org.eclipse.jgit.lib.Constants
9
9
import org.eclipse.jgit.transport.RemoteConfig
10
10
import org.eclipse.jgit.transport.URIish
11
11
import org.gradle.testfixtures.ProjectBuilder
12
- import pl.allegro.tech.build.axion.release.domain.scm.*
12
+ import pl.allegro.tech.build.axion.release.domain.scm.ScmException
13
+ import pl.allegro.tech.build.axion.release.domain.scm.ScmIdentity
14
+ import pl.allegro.tech.build.axion.release.domain.scm.ScmPosition
15
+ import pl.allegro.tech.build.axion.release.domain.scm.ScmProperties
16
+ import pl.allegro.tech.build.axion.release.domain.scm.ScmPushOptions
17
+ import pl.allegro.tech.build.axion.release.domain.scm.ScmRepositoryUnavailableException
18
+ import pl.allegro.tech.build.axion.release.domain.scm.TagsOnCommit
13
19
import pl.allegro.tech.build.axion.release.util.WithEnvironment
14
20
import spock.lang.Specification
15
21
@@ -71,50 +77,50 @@ class GitRepositoryTest extends Specification {
71
77
File lightweightTagRepositoryDir = File . createTempDir(' axion-release' , ' tmp' )
72
78
Map repositories = GitProjectBuilder . gitProject(lightweightTagRepositoryDir)
73
79
.withInitialCommit()
74
- .withLightweightTag(fullPrefix() + ' 1' )
80
+ .withLightweightTag(fullPrefix() + ' 1.0.0 ' )
75
81
.build()
76
82
77
83
GitRepository lightweightTagRepository = repositories[GitRepository ] as GitRepository
78
84
79
85
when :
80
- lightweightTagRepository. tag(fullPrefix() + ' 2' )
86
+ lightweightTagRepository. tag(fullPrefix() + ' 2.0.0 ' )
81
87
TagsOnCommit tags = lightweightTagRepository. latestTags(List . of(compile(' ^' + defaultPrefix() + ' .*' )))
82
88
83
89
then :
84
- tags. tags == [fullPrefix() + ' 1' , fullPrefix() + ' 2' ]
90
+ tags. tags == [fullPrefix() + ' 1.0.0 ' , fullPrefix() + ' 2.0.0 ' ]
85
91
}
86
92
87
93
def " should create new tag on current commit" () {
88
94
when :
89
- repository. tag(fullPrefix() + ' 1' )
95
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
90
96
91
97
then :
92
- rawRepository. tag. list()* . fullName == [' refs/tags/' + fullPrefix() + ' 1' ]
98
+ rawRepository. tag. list()* . fullName == [' refs/tags/' + fullPrefix() + ' 1.0.0 ' ]
93
99
}
94
100
95
101
def " should create tag when on HEAD even if it already exists on the same commit" () {
96
102
given :
97
- repository. tag(fullPrefix() + ' 1' )
103
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
98
104
99
105
when :
100
- repository. tag(fullPrefix() + ' 1' )
106
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
101
107
102
108
then :
103
- rawRepository. tag. list()* . fullName == [' refs/tags/' + fullPrefix() + ' 1' ]
109
+ rawRepository. tag. list()* . fullName == [' refs/tags/' + fullPrefix() + ' 1.0.0 ' ]
104
110
}
105
111
106
112
def " should throw an exception when creating new tag that already exists and it's not on HEAD" () {
107
113
given :
108
- repository. tag(fullPrefix() + ' 1' )
114
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
109
115
repository. commit([' *' ], " commit after release" )
110
116
111
117
when :
112
- repository. tag(fullPrefix() + ' 1' )
118
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
113
119
114
120
then :
115
121
ScmException e = thrown(ScmException )
116
122
e. getCause() instanceof RefAlreadyExistsException
117
- rawRepository. tag. list()* . fullName == [' refs/tags/' + fullPrefix() + ' 1' ]
123
+ rawRepository. tag. list()* . fullName == [' refs/tags/' + fullPrefix() + ' 1.0.0 ' ]
118
124
}
119
125
120
126
def " should create commit with given message" () {
@@ -135,14 +141,14 @@ class GitRepositoryTest extends Specification {
135
141
136
142
def " should return last tag in current position in simple case" () {
137
143
given :
138
- repository. tag(fullPrefix() + ' 1' )
144
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
139
145
repository. commit([' *' ], " commit after release" )
140
146
141
147
when :
142
148
TagsOnCommit tags = repository. latestTags(List . of(Pattern . compile(' ^' + defaultPrefix() + ' .*' )))
143
149
144
150
then :
145
- tags. tags == [fullPrefix() + ' 1' ]
151
+ tags. tags == [fullPrefix() + ' 1.0.0 ' ]
146
152
}
147
153
148
154
def " should return no tags when no commit in repository" () {
@@ -158,37 +164,37 @@ class GitRepositoryTest extends Specification {
158
164
159
165
def " should indicate that position is on tag when latest commit is tagged" () {
160
166
given :
161
- repository. tag(fullPrefix() + ' 1' )
167
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
162
168
163
169
when :
164
170
TagsOnCommit tags = repository. latestTags(List . of(Pattern . compile(' ' + defaultPrefix() + ' .*' )))
165
171
166
172
then :
167
- tags. tags == [fullPrefix() + ' 1' ]
173
+ tags. tags == [fullPrefix() + ' 1.0.0 ' ]
168
174
}
169
175
170
176
def " should track back to older tag when commit was made after checking out older version" () {
171
177
given :
172
- repository. tag(fullPrefix() + ' 1' )
178
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
173
179
repository. commit([' *' ], " commit after " + fullPrefix() + " 1" )
174
- repository. tag(fullPrefix() + ' 2' )
180
+ repository. tag(fullPrefix() + ' 2.0.0 ' )
175
181
repository. commit([' *' ], " commit after " + fullPrefix() + " 2" )
176
182
177
- rawRepository. checkout(branch : fullPrefix() + ' 1' )
183
+ rawRepository. checkout(branch : fullPrefix() + ' 1.0.0 ' )
178
184
repository. commit([' *' ], " bugfix after " + fullPrefix() + " 1" )
179
185
180
186
when :
181
187
TagsOnCommit tags = repository. latestTags(List . of(Pattern . compile(" ^" + defaultPrefix() + " .*" )))
182
188
183
189
then :
184
- tags. tags == [fullPrefix() + ' 1' ]
190
+ tags. tags == [fullPrefix() + ' 1.0.0 ' ]
185
191
}
186
192
187
193
def " should return all tagged commits matching the pattern provided" () {
188
194
given :
189
- repository. tag(fullPrefix() + ' 1' )
195
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
190
196
repository. commit([' *' ], " commit after " + fullPrefix() + " 1" )
191
- repository. tag(fullPrefix() + ' 2' )
197
+ repository. tag(fullPrefix() + ' 2.0.0 ' )
192
198
repository. commit([' *' ], " commit after " + fullPrefix() + " 2" )
193
199
repository. tag(' another-tag-1' )
194
200
repository. commit([' *' ], " commit after another-tag-1" )
@@ -202,20 +208,20 @@ class GitRepositoryTest extends Specification {
202
208
List<TagsOnCommit > allTaggedCommits = repository. taggedCommits(List . of(compile(' ^' + defaultPrefix() + ' .*' )))
203
209
204
210
then :
205
- allTaggedCommits. collect { c -> c. tags[0 ] } == [fullPrefix() + ' 3' , fullPrefix() + ' 4' , fullPrefix() + ' 2' , fullPrefix() + ' 1' ]
211
+ allTaggedCommits. collect { c -> c. tags[0 ] } == [fullPrefix() + ' 3' , fullPrefix() + ' 4' , fullPrefix() + ' 2.0.0 ' , fullPrefix() + ' 1.0.0 ' ]
206
212
}
207
213
208
214
def " should return only tags that match with prefix" () {
209
215
given :
210
- repository. tag(fullPrefix() + ' 1' )
216
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
211
217
repository. commit([' *' ], " commit after " + fullPrefix() + " 1" )
212
218
repository. tag(' otherTag' )
213
219
214
220
when :
215
221
TagsOnCommit tags = repository. latestTags(List . of(Pattern . compile(' ^' + defaultPrefix() + ' .*' )))
216
222
217
223
then :
218
- tags. tags == [fullPrefix() + ' 1' ]
224
+ tags. tags == [fullPrefix() + ' 1.0.0 ' ]
219
225
}
220
226
221
227
def " should return latest tagged commit before the given commit id" () {
@@ -235,14 +241,14 @@ class GitRepositoryTest extends Specification {
235
241
236
242
def " should return list of tags when multiple matching tags found on same commit" () {
237
243
given :
238
- repository. tag(fullPrefix() + ' 1' )
239
- repository. tag(fullPrefix() + ' 2' )
244
+ repository. tag(fullPrefix() + ' 1.0.0 ' )
245
+ repository. tag(fullPrefix() + ' 2.0.0 ' )
240
246
241
247
when :
242
248
TagsOnCommit tags = repository. latestTags(List . of(compile(' ^' + defaultPrefix() + ' .*' )))
243
249
244
250
then :
245
- tags. tags == [fullPrefix() + ' 1' , fullPrefix() + ' 2' ]
251
+ tags. tags == [fullPrefix() + ' 1.0.0 ' , fullPrefix() + ' 2.0.0 ' ]
246
252
}
247
253
248
254
def " should attach to remote repository" () {
@@ -656,7 +662,7 @@ class GitRepositoryTest extends Specification {
656
662
])
657
663
def ' should unshallow repo on CI' () {
658
664
given :
659
- remoteRepository. tag(fullPrefix() + ' 1' )
665
+ remoteRepository. tag(fullPrefix() + ' 1.0.0 ' )
660
666
100. times { remoteRepository. commit([' *' ], " commit after release" ) }
661
667
File repoDir = File . createTempDir(' axion-release' , ' tmp' )
662
668
Map repositories = GitProjectBuilder . gitProject(repoDir, remoteRepositoryDir, 1 ). build()
@@ -666,15 +672,15 @@ class GitRepositoryTest extends Specification {
666
672
TagsOnCommit tags = repository. latestTags(List . of(compile(' ^' + defaultPrefix() + ' .*' )))
667
673
668
674
then :
669
- tags. tags == [fullPrefix() + ' 1' ]
675
+ tags. tags == [fullPrefix() + ' 1.0.0 ' ]
670
676
}
671
677
672
678
@WithEnvironment ([
673
679
' CI=false'
674
680
])
675
681
def ' should not unshallow repo locally' () {
676
682
given :
677
- remoteRepository. tag(fullPrefix() + ' 1' )
683
+ remoteRepository. tag(fullPrefix() + ' 1.0.0 ' )
678
684
100. times { remoteRepository. commit([' *' ], " commit after release" ) }
679
685
File repoDir = File . createTempDir(' axion-release' , ' tmp' )
680
686
Map repositories = GitProjectBuilder . gitProject(repoDir, remoteRepositoryDir, 1 ). build()
0 commit comments