mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix: skip removed packages during upstream merge
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Match repository paths against exact, regex, or simple glob patterns.
|
||||
*/
|
||||
|
||||
function esc(text: string): string {
|
||||
return text.replace(/[|\\{}()[\]^$+?.]/g, "\\$&")
|
||||
}
|
||||
|
||||
function glob(pattern: string): RegExp {
|
||||
const source = pattern
|
||||
.split("**")
|
||||
.map((part) => part.split("*").map(esc).join("[^/]*"))
|
||||
.join(".*")
|
||||
|
||||
return new RegExp(`^${source}$`)
|
||||
}
|
||||
|
||||
export function match(path: string, pattern: string): boolean {
|
||||
if (path === pattern) return true
|
||||
|
||||
if (pattern.startsWith("^") || pattern.includes("\\")) {
|
||||
return new RegExp(pattern).test(path)
|
||||
}
|
||||
|
||||
if (pattern.includes("*")) {
|
||||
return glob(pattern).test(path)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
export function matches(path: string, patterns: string[]): boolean {
|
||||
return patterns.some((pattern) => match(path, pattern))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { getRecommendation } from "./report"
|
||||
|
||||
test("recommends skip for hosted package globs", () => {
|
||||
expect(getRecommendation("packages/web/src/content/docs/ja/zen.mdx", [], ["packages/web/**"]).recommendation).toBe(
|
||||
"skip",
|
||||
)
|
||||
expect(getRecommendation("packages/console/app/package.json", [], ["packages/console/**"]).recommendation).toBe(
|
||||
"skip",
|
||||
)
|
||||
})
|
||||
|
||||
test("does not recommend skip for unrelated packages", () => {
|
||||
expect(getRecommendation("packages/app/package.json", [], ["packages/web/**"]).recommendation).toBe(
|
||||
"package-transform",
|
||||
)
|
||||
})
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { $ } from "bun"
|
||||
import { matches } from "./match"
|
||||
|
||||
export interface ConflictReport {
|
||||
timestamp: string
|
||||
@@ -119,7 +120,7 @@ export function classifyFile(path: string): ConflictFile["type"] {
|
||||
* Check if a file should be skipped (not added from upstream)
|
||||
*/
|
||||
function shouldSkipFile(path: string, skipPatterns: string[]): boolean {
|
||||
return skipPatterns.some((pattern) => path === pattern || path.includes(pattern))
|
||||
return matches(path, skipPatterns)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user