Skip to content

Commit 50de9b2

Browse files
committed
Merge remote-tracking branch 'origin/main' into dfrancoeur/2979-gitignored
2 parents 57da7a8 + 144ebbd commit 50de9b2

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Thanks goes to these wonderful people for contributing to Scala Steward:
126126
* [Mark van der Tol](https://github.com/markvandertol)
127127
* [MaT1g3R](https://github.com/MaT1g3R)
128128
* [Mat Mannion](https://github.com/matmannion)
129+
* [Matthias Kurz](https://github.com/mkurz)
129130
* [Michael Wizner](https://github.com/mwz)
130131
* [Michel Daviot](https://github.com/tyrcho)
131132
* [miguelpuyol](https://github.com/miguelpuyol)
@@ -185,6 +186,7 @@ Consider creating PR to add your company to the list and join the community.
185186
* [Lightbend](https://www.lightbend.com/)
186187
* [Mobimeo](https://www.mobimeo.com/)
187188
* [Ocado Technology](https://ocadotechnology.com/)
189+
* [Play Framework](https://www.playframework.com/)
188190
* [PlayQ](https://www.playq.com/)
189191
* [Precog](https://precog.com/)
190192
* [Rewards Network](https://www.rewardsnetwork.com/)

modules/core/src/main/scala/org/scalasteward/core/buildtool/scalacli/ScalaCliAlg.scala

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,25 @@ final class ScalaCliAlg[F[_]](implicit
4141

4242
override def containsBuild(buildRoot: BuildRoot): F[Boolean] = {
4343
val buildRootPath = buildRoot.relativePath.dropWhile(Set('.', '/'))
44+
val extensions = Set(".sc", ".scala")
4445
gitAlg
4546
.findFilesContaining(buildRoot.repo, "//> using lib ")
46-
.map(_.exists(_.startsWith(buildRootPath)))
47+
.map(_.exists(path => path.startsWith(buildRootPath) && extensions.exists(path.endsWith)))
4748
}
4849

4950
override def getDependencies(buildRoot: BuildRoot): F[List[Scope.Dependencies]] =
5051
for {
5152
buildRootDir <- workspaceAlg.buildRootDir(buildRoot)
5253
exportDir = "tmp-sbt-build-for-scala-steward"
53-
exportCmd =
54-
Nel.of("scala-cli", "export", "--sbt", "--output", exportDir, buildRootDir.pathAsString)
54+
exportCmd = Nel.of(
55+
"scala-cli",
56+
"--power",
57+
"export",
58+
"--sbt",
59+
"--output",
60+
exportDir,
61+
buildRootDir.pathAsString
62+
)
5563
slurpOptions = SlurpOptions.ignoreBufferOverflow
5664
_ <- processAlg.execSandboxed(exportCmd, buildRootDir, slurpOptions = slurpOptions)
5765
exportBuildRoot = buildRoot.copy(relativePath = buildRoot.relativePath + s"/$exportDir")

modules/core/src/main/scala/org/scalasteward/core/git/FileGitAlg.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ final class FileGitAlg[F[_]](config: GitCfg)(implicit
5555
override def clone(repo: File, url: Uri): F[Unit] =
5656
for {
5757
rootDir <- workspaceAlg.rootDir
58-
_ <- git_("clone", url.toString, repo.pathAsString)(rootDir)
58+
_ <- git_("clone", "-c", "clone.defaultRemoteName=origin", url.toString, repo.pathAsString)(
59+
rootDir
60+
)
5961
} yield ()
6062

6163
override def cloneExists(repo: File): F[Boolean] =

modules/core/src/test/scala/org/scalasteward/core/buildtool/scalacli/ScalaCliAlgTest.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,25 @@ import org.scalasteward.core.buildtool.BuildRoot
55
import org.scalasteward.core.buildtool.sbt.command._
66
import org.scalasteward.core.data.{GroupId, Repo, Version}
77
import org.scalasteward.core.edit.scalafix.ScalafixMigration
8+
import org.scalasteward.core.git.FileGitAlg
89
import org.scalasteward.core.mock.MockContext.context._
910
import org.scalasteward.core.mock.MockState
1011
import org.scalasteward.core.mock.MockState.TraceEntry.{Cmd, Log}
1112
import org.scalasteward.core.util.Nel
1213

1314
class ScalaCliAlgTest extends CatsEffectSuite {
15+
test("containsBuild: directive in non-source file") {
16+
val repo = Repo("user", "repo")
17+
val buildRoot = BuildRoot(repo, ".")
18+
val fileWithUsingLib = "test.md" // this test fails if the extension is .scala or .sc
19+
val grepCmd = FileGitAlg.gitCmd.toList ++
20+
List("grep", "-I", "--fixed-strings", "--files-with-matches", "//> using lib ")
21+
val initial =
22+
MockState.empty.copy(commandOutputs = Map(grepCmd -> Right(List(fileWithUsingLib))))
23+
val obtained = scalaCliAlg.containsBuild(buildRoot).runA(initial)
24+
assertIO(obtained, false)
25+
}
26+
1427
test("getDependencies") {
1528
val repo = Repo("user", "repo")
1629
val buildRoot = BuildRoot(repo, ".")
@@ -28,6 +41,7 @@ class ScalaCliAlgTest extends CatsEffectSuite {
2841
"--env=VAR1=val1",
2942
"--env=VAR2=val2",
3043
"scala-cli",
44+
"--power",
3145
"export",
3246
"--sbt",
3347
"--output",

modules/core/src/test/scala/org/scalasteward/core/forge/ForgeRepoAlgTest.scala

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ class ForgeRepoAlgTest extends CatsEffectSuite {
3737
val expected = MockState.empty.copy(
3838
trace = Vector(
3939
Log("Clone scala-steward/datapackage"),
40-
Cmd(gitCmd(config.workspace), "clone", forkUrl, repoDir.toString),
40+
Cmd(
41+
gitCmd(config.workspace),
42+
"clone",
43+
"-c",
44+
"clone.defaultRemoteName=origin",
45+
forkUrl,
46+
repoDir.toString
47+
),
4148
Cmd(gitCmd(repoDir), "config", "user.email", "[email protected]"),
4249
Cmd(gitCmd(repoDir), "config", "user.name", "Bot Doe"),
4350
Log("Synchronize with fthomas/datapackage"),
@@ -64,7 +71,14 @@ class ForgeRepoAlgTest extends CatsEffectSuite {
6471
val expected = MockState.empty.copy(
6572
trace = Vector(
6673
Log("Clone fthomas/datapackage"),
67-
Cmd(gitCmd(config.workspace), "clone", parentUrl, repoDir.toString),
74+
Cmd(
75+
gitCmd(config.workspace),
76+
"clone",
77+
"-c",
78+
"clone.defaultRemoteName=origin",
79+
parentUrl,
80+
repoDir.toString
81+
),
6882
Cmd(gitCmd(repoDir), "config", "user.email", "[email protected]"),
6983
Cmd(gitCmd(repoDir), "config", "user.name", "Bot Doe"),
7084
Cmd(gitCmd(repoDir), "submodule", "update", "--init", "--recursive")

0 commit comments

Comments
 (0)