From e11bb7cb7ba0281d0ed7ec6ffaa4ceb28fbbcbe4 Mon Sep 17 00:00:00 2001 From: kirillk Date: Thu, 9 Apr 2026 12:30:48 -0400 Subject: [PATCH] fix(cli): skip opencode annotation check on upstream merge PRs --- .../workflows/check-opencode-annotations.yml | 7 ++++- script/check-opencode-annotations.ts | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-opencode-annotations.yml b/.github/workflows/check-opencode-annotations.yml index b2fc705dae..56c12b7932 100644 --- a/.github/workflows/check-opencode-annotations.yml +++ b/.github/workflows/check-opencode-annotations.yml @@ -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 diff --git a/script/check-opencode-annotations.ts b/script/check-opencode-annotations.ts index b953fd44d8..23d6470088 100644 --- a/script/check-opencode-annotations.ts +++ b/script/check-opencode-annotations.ts @@ -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 } { // --- 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) {