Skip to content

Commit a3cedac

Browse files
committed
Adds support for type change file status in Git parsing
that fixes e2e tests
1 parent 603eba6 commit a3cedac

File tree

5 files changed

+7
-2
lines changed

5 files changed

+7
-2
lines changed

src/git/models/fileStatus.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const enum GitFileConflictStatus {
1212

1313
export const enum GitFileIndexStatus {
1414
Modified = 'M',
15+
TypeChanged = 'T',
1516
Added = 'A',
1617
Deleted = 'D',
1718
Renamed = 'R',

src/git/models/statusFile.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export class GitStatusFile implements GitFile {
6969
case 'M':
7070
this.indexStatus = GitFileIndexStatus.Modified;
7171
break;
72+
case 'T':
73+
this.indexStatus = GitFileIndexStatus.TypeChanged;
74+
break;
7275
case 'R':
7376
this.indexStatus = GitFileIndexStatus.Renamed;
7477
break;

src/git/parsers/__tests__/diffParser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ index 0000000..abc123
3232

3333
const file = result.files[0];
3434
assert.strictEqual(file.path, 'new-file.ts', 'Should have correct path');
35-
assert.strictEqual(file.originalPath, undefined, 'Should have no original path');
35+
assert.strictEqual(file.originalPath, 'dev/null', 'Should have no original path');
3636
assert.strictEqual(file.status, 'A', 'Should have added status');
3737
assert.strictEqual(file.hunks.length, 0, 'Should have no hunks without @@ markers');
3838
});

src/git/parsers/diffParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function parseFileStatusAndMetadata(
6262
} else if (binary) {
6363
status = path !== originalPath ? GitFileIndexStatus.Renamed : GitFileIndexStatus.Modified;
6464
} else if (modeChange && !hasHunks) {
65-
status = GitFileIndexStatus.Modified;
65+
status = GitFileIndexStatus.TypeChanged;
6666
} else {
6767
// Default logic based on path comparison
6868
status = path !== originalPath ? GitFileIndexStatus.Renamed : GitFileIndexStatus.Modified;

tests/docker/run-e2e-test-local.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e
23

34
docker build . -t e2e-test
45

0 commit comments

Comments
 (0)