Skip to content

Commit 81ad6e3

Browse files
committed
Add CooldownConfig
To facilitate using dependency cooldowns, this commit adds a class CooldownConfig to represent a user’s desired cooldown settings: a list of ages (specified as finite durations, using the same string syntax as supported for pullRequests.frequency), each with a list of UpdatePatterns for the age to apply to.
1 parent a1dffde commit 81ad6e3

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2018-2025 Scala Steward contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.scalasteward.core.repoconfig
18+
19+
import io.circe.{Codec, Decoder, Encoder}
20+
import io.circe.generic.semiauto.deriveCodec
21+
import scala.concurrent.duration.FiniteDuration
22+
import cats.syntax.either.*
23+
24+
import org.scalasteward.core.util.dateTime.parseFiniteDuration
25+
26+
final case class CooldownConfig(
27+
age: FiniteDuration,
28+
artifacts: List[UpdatePattern] = List.empty
29+
)
30+
31+
object CooldownConfig {
32+
implicit val codec: Codec[CooldownConfig] = deriveCodec
33+
implicit val finiteDurationDecoder: Decoder[FiniteDuration] =
34+
Decoder[String].emap(s => parseFiniteDuration(s).leftMap(_.toString))
35+
implicit val finiteDurationEncoder: Encoder[FiniteDuration] =
36+
Encoder[String].contramap(_.toString)
37+
}

modules/core/src/main/scala/org/scalasteward/core/repoconfig/UpdatesConfig.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ final case class UpdatesConfig(
4040
private val ignore: Option[List[UpdatePattern]] = None,
4141
private val retracted: Option[List[RetractedArtifact]] = None,
4242
limit: Option[NonNegInt] = UpdatesConfig.defaultLimit,
43-
private val fileExtensions: Option[List[String]] = None
43+
private val fileExtensions: Option[List[String]] = None,
44+
private val cooldown: Option[List[CooldownConfig]] = None
4445
) {
4546
private[repoconfig] def pinOrDefault: List[UpdatePattern] =
4647
pin.getOrElse(Nil)

0 commit comments

Comments
 (0)