Skip to content

Commit 0301a92

Browse files
authored
Merge pull request #33 from ryancyq/skip-untracked
fix: add file changes process only git tracked files
2 parents a05e101 + 8a12850 commit 0301a92

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

__tests__/git.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('Git CLI', () => {
1919
const execMock = jest.spyOn(exec, 'exec').mockResolvedValue(0)
2020

2121
await switchBranch('new-branch')
22-
expect(execMock).toHaveBeenCalled()
2322
expect(execMock).toHaveBeenCalledWith(
2423
'git',
2524
['checkout', '-b', 'new-branch'],
@@ -97,7 +96,6 @@ describe('Git CLI', () => {
9796
.mockReturnValue(false)
9897

9998
await pushCurrentBranch()
100-
expect(execMock).toHaveBeenCalled()
10199
expect(execMock).toHaveBeenCalledWith(
102100
'git',
103101
['push', '--porcelain', '--set-upstream', 'origin', 'HEAD'],
@@ -190,7 +188,6 @@ describe('Git CLI', () => {
190188
const execMock = jest.spyOn(exec, 'exec').mockResolvedValue(0)
191189

192190
await addFileChanges(['*.ts', '~/.bashrc'])
193-
expect(execMock).toHaveBeenCalled()
194191
expect(execMock).toHaveBeenCalledWith(
195192
'git',
196193
['add', '--', '/test-workspace/*.ts', '/test-workspace/~/.bashrc'],
@@ -284,7 +281,13 @@ describe('Git CLI', () => {
284281
})
285282

286283
const changes = await getFileChanges()
287-
expect(execMock).toHaveBeenCalled()
284+
expect(execMock).toHaveBeenCalledWith(
285+
'git',
286+
['status', '-suno', '--porcelain'],
287+
expect.objectContaining({
288+
listeners: { stdline: expect.anything(), errline: expect.anything() },
289+
})
290+
)
288291
expect(changes).toBeDefined()
289292
expect(changes.additions).toBeDefined()
290293
expect(changes.additions).toHaveLength(5)

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30578,7 +30578,7 @@ function processFileChanges(output) {
3057830578
}
3057930579
function getFileChanges() {
3058030580
return __awaiter(this, void 0, void 0, function* () {
30581-
const { debug } = yield execGit(['status', '-suall', '--porcelain']);
30581+
const { debug } = yield execGit(['status', '-suno', '--porcelain']);
3058230582
const { additions, deletions } = processFileChanges(debug);
3058330583
const filesChanges = {};
3058430584
if (additions.length > 0) {

src/git.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function processFileChanges(output: string[]) {
8888
}
8989

9090
export async function getFileChanges(): Promise<FileChanges> {
91-
const { debug } = await execGit(['status', '-suall', '--porcelain'])
91+
const { debug } = await execGit(['status', '-suno', '--porcelain'])
9292
const { additions, deletions } = processFileChanges(debug)
9393
const filesChanges: FileChanges = {}
9494
if (additions.length > 0) {

0 commit comments

Comments
 (0)