mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-02 07:03:45 +00:00
fix(desktop): change detection on Windows, especially Cygwin (#13659)
Co-authored-by: LukeParkerDev <10430890+Hona@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,19 @@ import { Glob } from "../util/glob"
|
||||
|
||||
export namespace Project {
|
||||
const log = Log.create({ service: "project" })
|
||||
|
||||
function gitpath(cwd: string, name: string) {
|
||||
if (!name) return cwd
|
||||
// git output includes trailing newlines; keep path whitespace intact.
|
||||
name = name.replace(/[\r\n]+$/, "")
|
||||
if (!name) return cwd
|
||||
|
||||
name = Filesystem.windowsPath(name)
|
||||
|
||||
if (path.isAbsolute(name)) return path.normalize(name)
|
||||
return path.resolve(cwd, name)
|
||||
}
|
||||
|
||||
export const Info = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
@@ -141,7 +154,7 @@ export namespace Project {
|
||||
const top = await git(["rev-parse", "--show-toplevel"], {
|
||||
cwd: sandbox,
|
||||
})
|
||||
.then(async (result) => path.resolve(sandbox, (await result.text()).trim()))
|
||||
.then(async (result) => gitpath(sandbox, await result.text()))
|
||||
.catch(() => undefined)
|
||||
|
||||
if (!top) {
|
||||
@@ -159,9 +172,9 @@ export namespace Project {
|
||||
cwd: sandbox,
|
||||
})
|
||||
.then(async (result) => {
|
||||
const dirname = path.dirname((await result.text()).trim())
|
||||
if (dirname === ".") return sandbox
|
||||
return dirname
|
||||
const common = gitpath(sandbox, await result.text())
|
||||
// Avoid going to parent of sandbox when git-common-dir is empty.
|
||||
return common === sandbox ? sandbox : path.dirname(common)
|
||||
})
|
||||
.catch(() => undefined)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user