@@ -27,21 +27,26 @@ class EditAlgTest extends FunSuite {
2727 val update = (" org.typelevel" .g % " cats-core" .a % " 1.2.0" %> " 1.3.0" ).single
2828 val file1 = repoDir / " build.sbt"
2929 val file2 = repoDir / " project/Dependencies.scala"
30+ val gitignore = repoDir / " .gitignore"
3031
3132 val state = MockState .empty
32- .addFiles(file1 -> """ val catsVersion = "1.2.0"""" , file2 -> " " )
33+ .addFiles(file1 -> """ val catsVersion = "1.2.0"""" , file2 -> " " , gitignore -> " " )
3334 .flatMap(editAlg.applyUpdate(data, update).runS)
3435 .unsafeRunSync()
3536
3637 val expected = MockState .empty.copy(
3738 trace = Vector (
39+ Cmd (" read" , gitignore.pathAsString),
3840 Cmd (" test" , " -f" , repoDir.pathAsString),
41+ Cmd (" test" , " -f" , gitignore.pathAsString),
3942 Cmd (" test" , " -f" , file1.pathAsString),
4043 Cmd (" read" , file1.pathAsString),
4144 Cmd (" test" , " -f" , (repoDir / " project" ).pathAsString),
4245 Cmd (" test" , " -f" , file2.pathAsString),
4346 Cmd (" read" , file2.pathAsString),
47+ Cmd (" read" , gitignore.pathAsString),
4448 Cmd (" test" , " -f" , repoDir.pathAsString),
49+ Cmd (" test" , " -f" , gitignore.pathAsString),
4550 Cmd (" test" , " -f" , file1.pathAsString),
4651 Cmd (" read" , file1.pathAsString),
4752 Cmd (" test" , " -f" , (repoDir / " project" ).pathAsString),
@@ -51,7 +56,7 @@ class EditAlgTest extends FunSuite {
5156 Cmd (" write" , file1.pathAsString),
5257 Cmd (gitStatus(repoDir))
5358 ),
54- files = Map (file1 -> """ val catsVersion = "1.3.0"""" , file2 -> " " )
59+ files = Map (file1 -> """ val catsVersion = "1.3.0"""" , file2 -> " " , gitignore -> " " )
5560 )
5661
5762 assertEquals(state, expected)
@@ -65,30 +70,47 @@ class EditAlgTest extends FunSuite {
6570 val data = RepoData (repo, cache, RepoConfig .empty)
6671 val repoDir = workspaceAlg.repoDir(repo).unsafeRunSync()
6772 val update = (" org.scalameta" .g % " scalafmt-core" .a % " 2.0.0" %> " 2.1.0" ).single
73+ val gitignore = repoDir / " .gitignore"
6874 val scalafmtConf = repoDir / scalafmtConfName
6975 val scalafmtConfContent = """ maxColumn = 100
7076 |version = 2.0.0
7177 |align.openParenCallSite = false
7278 |""" .stripMargin
7379 val buildSbt = repoDir / " build.sbt"
80+ val target = repoDir / " target"
81+ // this file should not be read because it's under target which is git ignored
82+ val targetScalaFile = target / " SomeFile.scala"
7483
7584 val state = MockState .empty
76- .addFiles(scalafmtConf -> scalafmtConfContent, buildSbt -> " " )
85+ .addFiles(
86+ scalafmtConf -> scalafmtConfContent,
87+ buildSbt -> " " ,
88+ gitignore -> " target/" ,
89+ targetScalaFile -> " "
90+ )
7791 .flatMap(editAlg.applyUpdate(data, update).runS)
7892 .unsafeRunSync()
7993
8094 val expected = MockState .empty.copy(
8195 trace = Vector (
96+ Cmd (" read" , gitignore.pathAsString),
8297 Cmd (" test" , " -f" , repoDir.pathAsString),
98+ Cmd (" test" , " -f" , gitignore.pathAsString),
8399 Cmd (" test" , " -f" , scalafmtConf.pathAsString),
84100 Cmd (" read" , scalafmtConf.pathAsString),
85101 Cmd (" test" , " -f" , buildSbt.pathAsString),
86102 Cmd (" read" , buildSbt.pathAsString),
103+ Cmd (" test" , " -f" , target.pathAsString),
104+ Cmd (" test" , " -f" , targetScalaFile.pathAsString),
105+ Cmd (" read" , gitignore.pathAsString),
87106 Cmd (" test" , " -f" , repoDir.pathAsString),
107+ Cmd (" test" , " -f" , gitignore.pathAsString),
88108 Cmd (" test" , " -f" , scalafmtConf.pathAsString),
89109 Cmd (" read" , scalafmtConf.pathAsString),
90110 Cmd (" test" , " -f" , buildSbt.pathAsString),
91111 Cmd (" read" , buildSbt.pathAsString),
112+ Cmd (" test" , " -f" , target.pathAsString),
113+ Cmd (" test" , " -f" , targetScalaFile.pathAsString),
92114 Cmd (" read" , scalafmtConf.pathAsString),
93115 Cmd (" write" , scalafmtConf.pathAsString),
94116 Cmd (
@@ -109,7 +131,9 @@ class EditAlgTest extends FunSuite {
109131 |version = 2.1.0
110132 |align.openParenCallSite = false
111133 |""" .stripMargin,
112- buildSbt -> " "
134+ buildSbt -> " " ,
135+ gitignore -> " target/" ,
136+ targetScalaFile -> " "
113137 )
114138 )
115139
0 commit comments