feat(FN-2944): merge fusion/fn-2944
- test(FN-2944): cover already checked out worktree conflict recovery - fix(FN-2944): recognize git already checked out worktree conflict - fix(engine): auto-recover from squash-merge orphan rebase failures Fusion-Task-Id: FN-2944
This commit is contained in:
@@ -14,3 +14,11 @@ import { join } from "node:path";
|
||||
|
||||
const tempHome = mkdtempSync(join(tmpdir(), "fn-test-home-"));
|
||||
process.env.HOME = tempHome;
|
||||
process.env.USERPROFILE = tempHome;
|
||||
if (process.platform === "win32") {
|
||||
const match = tempHome.match(/^([A-Za-z]:)(.*)$/);
|
||||
if (match) {
|
||||
process.env.HOMEDRIVE = match[1];
|
||||
process.env.HOMEPATH = match[2] || "\\";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,19 +20,23 @@ import { existsSync, mkdirSync, renameSync } from "node:fs";
|
||||
import type { GlobalSettings } from "./types.js";
|
||||
import { DEFAULT_GLOBAL_SETTINGS } from "./types.js";
|
||||
|
||||
function getHomeDir(): string {
|
||||
return process.env.HOME || process.env.USERPROFILE || homedir();
|
||||
}
|
||||
|
||||
/** Legacy directory for global settings (original name before rename to `.fusion`). */
|
||||
export function legacyGlobalDir(): string {
|
||||
return join(homedir(), ".pi", "fusion");
|
||||
return join(getHomeDir(), ".pi", "fusion");
|
||||
}
|
||||
|
||||
/** Legacy directory for global settings from the earliest fn version (`.pi/kb`). */
|
||||
export function legacyGlobalDirOriginal(): string {
|
||||
return join(homedir(), ".pi", "kb");
|
||||
return join(getHomeDir(), ".pi", "kb");
|
||||
}
|
||||
|
||||
/** Default directory for global fusion settings: `~/.fusion/` */
|
||||
export function defaultGlobalDir(): string {
|
||||
return join(homedir(), ".fusion");
|
||||
return join(getHomeDir(), ".fusion");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,10 @@ import { isAbsolute, join, resolve, basename, dirname } from "node:path";
|
||||
import type { CentralCore } from "./central-core.js";
|
||||
import { CentralCore as CentralCoreClass } from "./central-core.js";
|
||||
|
||||
function getHomeDir(): string {
|
||||
return process.env.HOME || process.env.USERPROFILE || homedir();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether `<dir>/<folderName>/<dbName>` exists as a non-empty regular file.
|
||||
* Used to decide if a directory contains a current (.fusion/fusion.db) project database.
|
||||
@@ -192,7 +196,7 @@ export class FirstRunDetector {
|
||||
const visited = new Set<string>();
|
||||
|
||||
let current = resolve(startDir);
|
||||
const home = homedir();
|
||||
const home = getHomeDir();
|
||||
const root = dirname(current) === current ? current : "/"; // Handle Windows vs Unix root
|
||||
// Also stop at the OS temp directory — it is a shared system boundary and
|
||||
// should never itself host a project; stopping here prevents the walk from
|
||||
@@ -299,7 +303,7 @@ export class FirstRunDetector {
|
||||
}
|
||||
|
||||
private getDefaultGlobalDir(): string {
|
||||
return join(homedir(), ".pi", "kb");
|
||||
return join(getHomeDir(), ".pi", "kb");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user