mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-01 14:12:51 +00:00
fix(git): discard repository paths from the worktree root
This commit is contained in:
@@ -3556,13 +3556,13 @@ export async function commitAll(cwd: string, message: string): Promise<void> {
|
||||
}
|
||||
|
||||
export async function discardChanges(cwd: string, pathspecs: string[]): Promise<void> {
|
||||
await requireGitRepo(cwd);
|
||||
const worktreeRoot = await requireGitWorktreeRoot(cwd);
|
||||
if (pathspecs.length === 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await runGitCommand(["--literal-pathspecs", "reset", "-q", "HEAD", "--", ...pathspecs], {
|
||||
cwd,
|
||||
cwd: worktreeRoot,
|
||||
timeout: DISCARD_CHANGES_TIMEOUT_MS,
|
||||
});
|
||||
} catch {
|
||||
@@ -3570,7 +3570,7 @@ export async function discardChanges(cwd: string, pathspecs: string[]): Promise<
|
||||
await runGitCommand(
|
||||
["--literal-pathspecs", "rm", "--cached", "-r", "-q", "--ignore-unmatch", "--", ...pathspecs],
|
||||
{
|
||||
cwd,
|
||||
cwd: worktreeRoot,
|
||||
timeout: DISCARD_CHANGES_TIMEOUT_MS,
|
||||
},
|
||||
);
|
||||
@@ -3582,7 +3582,7 @@ export async function discardChanges(cwd: string, pathspecs: string[]): Promise<
|
||||
const status = await runGitCommand(
|
||||
["--literal-pathspecs", "status", "--porcelain=v1", "-z", "--", ...pathspecs],
|
||||
{
|
||||
cwd,
|
||||
cwd: worktreeRoot,
|
||||
timeout: DISCARD_CHANGES_TIMEOUT_MS,
|
||||
},
|
||||
);
|
||||
@@ -3608,13 +3608,13 @@ export async function discardChanges(cwd: string, pathspecs: string[]): Promise<
|
||||
}
|
||||
if (tracked.length > 0) {
|
||||
await runGitCommand(["--literal-pathspecs", "checkout", "-q", "--", ...tracked], {
|
||||
cwd,
|
||||
cwd: worktreeRoot,
|
||||
timeout: DISCARD_CHANGES_TIMEOUT_MS,
|
||||
});
|
||||
}
|
||||
if (untracked.length > 0) {
|
||||
await runGitCommand(["--literal-pathspecs", "clean", "-fd", "-q", "--", ...untracked], {
|
||||
cwd,
|
||||
cwd: worktreeRoot,
|
||||
timeout: DISCARD_CHANGES_TIMEOUT_MS,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user