Skip to content

Commit 59540d1

Browse files
koki-developclaude
andcommitted
feat: Add Git class for git operations
- Create src/lib/git.ts with Git class - Implement isInited() method to check git initialization - Implement lsFiles() method to get git-tracked files - Refactor FileEditor to use Git class instead of direct simple-git usage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2bc8584 commit 59540d1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/lib/git.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import simpleGit from "simple-git";
2+
3+
export class Git {
4+
private git = simpleGit();
5+
6+
async isInited(): Promise<boolean> {
7+
return await this.git
8+
.status()
9+
.then(() => true)
10+
.catch(() => false);
11+
}
12+
13+
async lsFiles(): Promise<string[]> {
14+
const gitFiles = await this.git.raw(["ls-files"]);
15+
return gitFiles
16+
.trim()
17+
.split("\n")
18+
.filter((file) => file.trim() !== "");
19+
}
20+
}

0 commit comments

Comments
 (0)