Skip to content

Commit 8a75d49

Browse files
Merge commit '8f18368bc' into merge-upstream
2 parents b7d95df + 8f18368 commit 8a75d49

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

build.sbt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ lazy val sonatypeSetting = Def.settings(
2626

2727
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"
2828

29+
// Add hook for scalafmt validation
30+
Global / onLoad ~= { old =>
31+
if (!scala.util.Properties.isWin) {
32+
import java.nio.file._
33+
val prePush = Paths.get(".git", "hooks", "pre-push")
34+
Files.createDirectories(prePush.getParent)
35+
Files.write(
36+
prePush,
37+
"""#!/bin/sh
38+
|set -eux
39+
|bin/scalafmt --diff --diff-branch main
40+
|git diff --exit-code
41+
|""".stripMargin.getBytes()
42+
)
43+
prePush.toFile.setExecutable(true)
44+
}
45+
old
46+
}
47+
2948
val scalafixSettings: Seq[Setting[_]] = Seq(
3049
scalacOptions ++= {
3150
if (scalaVersion.value.startsWith("2.11")) Seq("-Ywarn-unused-import")

0 commit comments

Comments
 (0)