Skip to content

Commit 1d60a7c

Browse files
committed
Fix spotless ratcheting on release branches (#1401)
1 parent a487972 commit 1d60a7c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

buildSrc/src/main/kotlin/pklAllProjects.gradle.kts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
2+
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -142,9 +142,17 @@ private fun KotlinGradleExtension.configureFormatter() {
142142
}
143143

144144
val originalRemoteName = System.getenv("PKL_ORIGINAL_REMOTE_NAME") ?: "origin"
145+
// if we're running against a release branch (or a PR targeted at one), use that branch for
146+
// ratcheting
147+
// these env vars are set by GitHub actions:
148+
// https://docs.github.com/en/actions/reference/workflows-and-actions/variables#default-environment-variables
149+
val ratchetBranchName =
150+
(System.getenv("GITHUB_BASE_REF") ?: System.getenv("GITHUB_REF_NAME"))?.let {
151+
if (it.startsWith("release/")) it else null
152+
} ?: "main"
145153

146154
spotless {
147-
ratchetFrom = "$originalRemoteName/main"
155+
ratchetFrom = "$originalRemoteName/$ratchetBranchName"
148156

149157
// When building root project, format buildSrc files too.
150158
// We need this because buildSrc is not a subproject of the root project, so a top-level

0 commit comments

Comments
 (0)