fix(cli): skip opencode annotation check on upstream merge PRs

This commit is contained in:
kirillk
2026-04-09 12:30:48 -04:00
parent 2e69c4c31d
commit e11bb7cb7b
2 changed files with 36 additions and 1 deletions
@@ -11,7 +11,12 @@ on:
jobs:
check-annotations:
name: Check kilocode_change annotations
if: github.repository == 'Kilo-Org/kilocode'
if: >-
github.repository == 'Kilo-Org/kilocode' &&
(
github.event_name != 'pull_request' ||
!contains(github.event.pull_request.head.ref, 'kilo-opencode-')
)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
+30
View File
@@ -50,6 +50,30 @@ function changedFiles() {
return out ? out.split("\n").filter(Boolean) : []
}
function branch() {
return process.env.GITHUB_HEAD_REF || process.env.HEAD_REF || run("git", ["branch", "--show-current"])
}
function commits() {
const out = run("git", ["log", "--format=%P%x09%s", `${base}..HEAD`])
return out ? out.split("\n").filter(Boolean) : []
}
function skip() {
const name = branch()
if (name.includes("kilo-opencode-")) {
return `upstream merge branch '${name}'`
}
const hit = commits().find((line) => {
const [parents = "", subject = ""] = line.split("\t")
return parents.includes(" ") && subject.startsWith("merge: upstream ")
})
if (hit) return "upstream merge commit"
return ""
}
function isExempt(file: string) {
const norm = file.replaceAll("\\", "/").toLowerCase()
return norm.split("/").some((part) => part.includes("kilocode"))
@@ -120,6 +144,12 @@ function coveredLines(text: string): { lines: string[]; covered: Set<number> } {
// --- main ---
const why = skip()
if (why) {
console.log(`Skipping opencode annotation check for ${why}.`)
process.exit(0)
}
const files = changedFiles().filter((f) => !isExempt(f) && isSource(f))
if (files.length === 0) {