diff --git a/buildSrc/src/main/kotlin/pklAllProjects.gradle.kts b/buildSrc/src/main/kotlin/pklAllProjects.gradle.kts index 141fa8ca..7d39c39e 100644 --- a/buildSrc/src/main/kotlin/pklAllProjects.gradle.kts +++ b/buildSrc/src/main/kotlin/pklAllProjects.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -142,9 +142,17 @@ private fun KotlinGradleExtension.configureFormatter() { } val originalRemoteName = System.getenv("PKL_ORIGINAL_REMOTE_NAME") ?: "origin" +// if we're running against a release branch (or a PR targeted at one), use that branch for +// ratcheting +// these env vars are set by GitHub actions: +// https://docs.github.com/en/actions/reference/workflows-and-actions/variables#default-environment-variables +val ratchetBranchName = + (System.getenv("GITHUB_BASE_REF") ?: System.getenv("GITHUB_REF_NAME"))?.let { + if (it.startsWith("release/")) it else null + } ?: "main" spotless { - ratchetFrom = "$originalRemoteName/main" + ratchetFrom = "$originalRemoteName/$ratchetBranchName" // When building root project, format buildSrc files too. // We need this because buildSrc is not a subproject of the root project, so a top-level