@@ -6,7 +6,13 @@ import cats.effect.IO
6
6
import cats .syntax .all ._
7
7
import munit .CatsEffectSuite
8
8
import org .scalasteward .core .TestInstances .ioLogger
9
- import org .scalasteward .core .git .FileGitAlgTest .{ioAuxGitAlg , ioGitAlg , master }
9
+ import org .scalasteward .core .git .FileGitAlgTest .{
10
+ conflictsNo ,
11
+ conflictsYes ,
12
+ ioAuxGitAlg ,
13
+ ioGitAlg ,
14
+ master
15
+ }
10
16
import org .scalasteward .core .io .FileAlgTest .ioFileAlg
11
17
import org .scalasteward .core .io .ProcessAlgTest .ioProcessAlg
12
18
import org .scalasteward .core .io .{FileAlg , ProcessAlg , WorkspaceAlg }
@@ -47,7 +53,7 @@ class FileGitAlgTest extends CatsEffectSuite {
47
53
for {
48
54
_ <- ioAuxGitAlg.createRepo(repo)
49
55
_ <- ioAuxGitAlg.createConflict(repo)
50
- authors <- ioGitAlg.branchAuthors(repo, Branch ( " conflicts-no " ) , master)
56
+ authors <- ioGitAlg.branchAuthors(repo, conflictsNo , master)
51
57
_ = assertEquals(authors, List (" 'Bot Doe'" ))
52
58
} yield ()
53
59
}
@@ -157,57 +163,37 @@ class FileGitAlgTest extends CatsEffectSuite {
157
163
for {
158
164
_ <- ioAuxGitAlg.createRepo(repo)
159
165
_ <- ioAuxGitAlg.createConflict(repo)
160
- c1 <- ioGitAlg.hasConflicts(repo, Branch ( " conflicts-yes " ) , master)
161
- c2 <- ioGitAlg.hasConflicts(repo, Branch ( " conflicts-no " ) , master)
166
+ c1 <- ioGitAlg.hasConflicts(repo, conflictsYes , master)
167
+ c2 <- ioGitAlg.hasConflicts(repo, conflictsNo , master)
162
168
_ = assertEquals((c1, c2), (true , false ))
163
169
} yield ()
164
170
}
165
171
166
- test(" mergeTheirs " ) {
167
- val repo = rootDir / " mergeTheirs "
172
+ test(" isMerged " ) {
173
+ val repo = rootDir / " isMerged "
168
174
for {
169
175
_ <- ioAuxGitAlg.createRepo(repo)
170
176
_ <- ioAuxGitAlg.createConflict(repo)
171
- branch = Branch (" conflicts-yes" )
172
- c1 <- ioGitAlg.hasConflicts(repo, branch, master)
173
- m1 <- ioGitAlg.isMerged(repo, master, branch)
174
- _ <- ioGitAlg.checkoutBranch(repo, branch)
175
- _ <- ioGitAlg.mergeTheirs(repo, master)
176
- c2 <- ioGitAlg.hasConflicts(repo, branch, master)
177
- m2 <- ioGitAlg.isMerged(repo, master, branch)
178
- _ = assertEquals((c1, m1, c2, m2), (true , false , false , true ))
179
- } yield ()
180
- }
181
-
182
- test(" mergeTheirs: CONFLICT (modify/delete)" ) {
183
- val repo = rootDir / " mergeTheirs-modify-delete"
184
- for {
185
- _ <- ioAuxGitAlg.createRepo(repo)
186
- _ <- ioAuxGitAlg.createConflictFileRemovedOnMaster(repo)
187
- branch = Branch (" conflicts-yes" )
188
- c1 <- ioGitAlg.hasConflicts(repo, branch, master)
189
- m1 <- ioGitAlg.isMerged(repo, master, branch)
190
- _ <- ioGitAlg.checkoutBranch(repo, branch)
191
- _ <- ioGitAlg.mergeTheirs(repo, master)
192
- c2 <- ioGitAlg.hasConflicts(repo, branch, master)
193
- m2 <- ioGitAlg.isMerged(repo, master, branch)
194
- _ = assertEquals((c1, m1, c2, m2), (true , false , false , true ))
177
+ m1 <- ioGitAlg.isMerged(repo, conflictsNo, master)
178
+ _ <- ioAuxGitAlg.git(" merge" , conflictsNo.name)(repo)
179
+ m2 <- ioGitAlg.isMerged(repo, conflictsNo, master)
180
+ _ = assertEquals((m1, m2), (false , true ))
195
181
} yield ()
196
182
}
197
183
198
- test(" revertChanges " ) {
199
- val repo = rootDir / " revertChanges "
184
+ test(" resetHard " ) {
185
+ val repo = rootDir / " resetHard "
200
186
for {
201
187
_ <- ioAuxGitAlg.createRepo(repo)
202
188
_ <- ioAuxGitAlg.createConflict(repo)
203
- branch = Branch ( " conflicts-yes " )
189
+ branch = conflictsYes
204
190
c1 <- ioGitAlg.hasConflicts(repo, branch, master)
205
191
d1 <- ioGitAlg.branchesDiffer(repo, master, branch)
206
192
_ <- ioGitAlg.checkoutBranch(repo, branch)
207
- _ <- ioGitAlg.revertChanges (repo, master)
193
+ _ <- ioGitAlg.resetHard (repo, master)
208
194
c2 <- ioGitAlg.hasConflicts(repo, branch, master)
209
195
d2 <- ioGitAlg.branchesDiffer(repo, master, branch)
210
- _ = assertEquals((c1, d1, c2, d2), (true , true , false , true ))
196
+ _ = assertEquals((c1, d1, c2, d2), (true , true , false , false ))
211
197
} yield ()
212
198
}
213
199
@@ -217,7 +203,9 @@ class FileGitAlgTest extends CatsEffectSuite {
217
203
}
218
204
219
205
object FileGitAlgTest {
220
- val master : Branch = Branch (" master" )
206
+ private val master : Branch = Branch (" master" )
207
+ private val conflictsNo : Branch = Branch (" conflicts-no" )
208
+ private val conflictsYes : Branch = Branch (" conflicts-yes" )
221
209
222
210
final class AuxGitAlg [F [_]](implicit
223
211
fileAlg : FileAlg [F ],
@@ -250,13 +238,13 @@ object FileGitAlgTest {
250
238
_ <- fileAlg.writeFile(repo / " file2" , " file2, line1" )
251
239
_ <- addFiles(repo, repo / " file1" , repo / " file2" )
252
240
// work on conflicts-no
253
- _ <- gitAlg.createBranch(repo, Branch ( " conflicts-no " ) )
241
+ _ <- gitAlg.createBranch(repo, conflictsNo )
254
242
_ <- fileAlg.writeFile(repo / " file3" , " file3, line1" )
255
243
_ <- git(" add" , " file3" )(repo)
256
244
_ <- gitAlg.commitAll(repo, CommitMsg (" Add file3 on conflicts-no" ))
257
245
_ <- gitAlg.checkoutBranch(repo, master)
258
246
// work on conflicts-yes
259
- _ <- gitAlg.createBranch(repo, Branch ( " conflicts-yes " ) )
247
+ _ <- gitAlg.createBranch(repo, conflictsYes )
260
248
_ <- fileAlg.writeFile(repo / " file2" , " file2, line1\n file2, line2 on conflicts-yes" )
261
249
_ <- git(" add" , " file2" )(repo)
262
250
_ <- gitAlg.commitAll(repo, CommitMsg (" Modify file2 on conflicts-yes" ))
@@ -274,7 +262,7 @@ object FileGitAlgTest {
274
262
_ <- fileAlg.writeFile(repo / " file2" , " file2, line1" )
275
263
_ <- addFiles(repo, repo / " file1" , repo / " file2" )
276
264
// work on conflicts-yes
277
- _ <- gitAlg.createBranch(repo, Branch ( " conflicts-yes " ) )
265
+ _ <- gitAlg.createBranch(repo, conflictsYes )
278
266
_ <- fileAlg.writeFile(repo / " file2" , " file2, line1\n file2, line2 on conflicts-yes" )
279
267
_ <- git(" add" , " file2" )(repo)
280
268
_ <- gitAlg.commitAll(repo, CommitMsg (" Modify file2 on conflicts-yes" ))
0 commit comments