mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-29 03:44:06 +08:00
fix(cli): skip opencode annotation check on upstream merge PRs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user