Skip to content

Commit c1ea445

Browse files
authored
Merge pull request #552 from typelevel/pr/fix-tlPrePrBotHook
`tlPrePRBotHook` should respect ci config
2 parents 39cc5bf + ec6d2f2 commit c1ea445

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

core/src/main/scala/org/typelevel/sbt/TypelevelPlugin.scala

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,7 @@ object TypelevelPlugin extends AutoPlugin {
7777
java <- githubWorkflowJavaVersions.value.tail // default java is head
7878
} yield MatrixExclude(Map("scala" -> scala, "java" -> java.render))
7979
}
80-
) ++ addPrePRCommandAlias ++ addCommandAlias(
81-
"tlPrePrBotHook",
82-
mkCommand(
83-
List(
84-
"githubWorkflowGenerate",
85-
"+headerCreateAll",
86-
"+scalafmtAll",
87-
"scalafmtSbt"
88-
)
89-
)
90-
)
80+
) ++ addPrePRCommandAlias ++ addTlPrePRBotHookCommandAlias
9181

9282
// partially re-implemnents addCommandAlias
9383
// this is so we can use the value of other settings to generate command
@@ -114,4 +104,25 @@ object TypelevelPlugin extends AutoPlugin {
114104
}
115105
)
116106

107+
private def addTlPrePRBotHookCommandAlias: Seq[Setting[_]] = Seq(
108+
GlobalScope / onLoad := {
109+
val header = tlCiHeaderCheck.value
110+
val scalafmt = tlCiScalafmtCheck.value
111+
112+
(GlobalScope / Keys.onLoad).value.compose { (state: State) =>
113+
val command = mkCommand(
114+
List("githubWorkflowGenerate") ++
115+
List("+headerCreateAll").filter(_ => header) ++
116+
List("+scalafmtAll", "scalafmtSbt").filter(_ => scalafmt)
117+
)
118+
BasicCommands.addAlias(state, "tlPrePrBotHook", command)
119+
}
120+
},
121+
GlobalScope / Keys.onUnload := {
122+
(GlobalScope / Keys.onUnload)
123+
.value
124+
.compose((state: State) => BasicCommands.removeAlias(state, "tlPrePrBotHook"))
125+
}
126+
)
127+
117128
}

0 commit comments

Comments
 (0)