Skip to content

Commit

Permalink
Merge pull request #19 from ChenCMD/ChenCMD/issue18
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenCMD authored Aug 13, 2023
2 parents f1bd7d4 + fb223ce commit dc512a8
Showing 1 changed file with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import scala.scalajs.js
import scala.scalajs.js.JSConverters.*

import typings.actionsCache.mod as cache
import typings.octokitWebhooksTypes.mod.PushEvent

object GitHubManageCache {
def createInstr[F[_]: Async](cacheVersion: Int): F[CIPlatformManageCacheInstr[F]] = for {
Expand Down Expand Up @@ -42,18 +41,7 @@ object GitHubManageCache {
}
}

val prevBranch = {
val created = ghCtx.eventName == "push"
&& ghCtx.payload.asInstanceOf[PushEvent].created
if (created) {
ghCtx.payload.get("base_ref").flatMap(_.asInstanceOf[js.UndefOr[js.Any]].toOption).map(_.toString)
} else {
Some(ghCtx.ref)
}
}

val fallbackKey = makeCacheKey()
prevBranch.map(makeCacheKey).fold(_restore(fallbackKey))(_restore(_, List(fallbackKey)))
_restore(makeCacheKey(ghCtx.ref), List(makeCacheKey()))
}

private def makeCacheKey(branch: String = "") = {
Expand Down

0 comments on commit dc512a8

Please sign in to comment.