Skip to content

Commit 5483881

Browse files
committed
fix: don't discard ignored files
close #1006
1 parent d64e4d7 commit 5483881

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/gitManager/simpleGit.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { normalizePath, Notice, Platform } from "obsidian";
55
import * as path from "path";
66
import { resolve, sep } from "path";
77
import type * as simple from "simple-git";
8-
import simpleGit, { GitError } from "simple-git";
8+
import simpleGit, { GitError, CleanOptions } from "simple-git";
99
import {
1010
ASK_PASS_INPUT_FILE,
1111
ASK_PASS_SCRIPT,
@@ -569,19 +569,17 @@ export class SimpleGit extends GitManager {
569569
async getUntrackedPaths(opts: { path?: string }): Promise<string[]> {
570570
const dir = opts?.path;
571571
this.plugin.setPluginState({ gitAction: CurrentGitAction.status });
572-
const args = [
573-
"ls-files",
574-
"--others",
575-
"--exclude-standard",
576-
"--directory",
577-
];
572+
const args = [];
578573
if (dir != undefined) {
579574
args.push("--", dir);
580575
}
581-
const untrackedFiles = await this.git.raw(args);
582-
this.plugin.setPluginState({ gitAction: CurrentGitAction.idle });
576+
const untrackedFiles = await this.git.clean(
577+
CleanOptions.RECURSIVE + CleanOptions.DRY_RUN,
578+
args
579+
);
583580

584-
return untrackedFiles.split(/\r\n|\r|\n/).filter((e) => e.length > 0);
581+
this.plugin.setPluginState({ gitAction: CurrentGitAction.idle });
582+
return untrackedFiles.paths;
585583
}
586584

587585
async hashObject(filepath: string): Promise<string> {

0 commit comments

Comments
 (0)