-
-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add status to DiffResult * add changeset * fix: handle rename in log --name-status * fix: add status to DiffResultBinaryFile * Support for renamed files in `--name-status` in `git.log` where the file name is a single character. Add integration test for name-status renames. --------- Co-authored-by: Vinzent <[email protected]>
- Loading branch information
Showing
10 changed files
with
131 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'simple-git': minor | ||
--- | ||
|
||
add status to DiffResult when using --name-status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export enum DiffNameStatus { | ||
ADDED = 'A', | ||
COPIED = 'C', | ||
DELETED = 'D', | ||
MODIFIED = 'M', | ||
RENAMED = 'R', | ||
CHANGED = 'T', | ||
UNMERGED = 'U', | ||
UNKNOWN = 'X', | ||
BROKEN = 'B', | ||
} | ||
|
||
const diffNameStatus = new Set(Object.values(DiffNameStatus)); | ||
|
||
export function isDiffNameStatus(input: string): input is DiffNameStatus { | ||
return diffNameStatus.has(input as DiffNameStatus); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
createTestContext, | ||
like, | ||
newSimpleGit, | ||
setUpFilesAdded, | ||
setUpInit, | ||
SimpleGitTestContext, | ||
} from '@simple-git/test-utils'; | ||
|
||
import { DiffNameStatus, DiffResultTextFile } from '../..'; | ||
|
||
describe('log-name-status', function () { | ||
let context: SimpleGitTestContext; | ||
const steps = ['mv a b', 'commit -m two']; | ||
|
||
beforeEach(async () => { | ||
context = await createTestContext(); | ||
await setUpInit(context); | ||
await setUpFilesAdded(context, ['a'], '.', 'one'); | ||
for (const step of steps) { | ||
await context.git.raw(step.split(' ')); | ||
} | ||
}); | ||
|
||
it('detects files moved with --name-status', async () => { | ||
const actual = await newSimpleGit(context.root).log(['--name-status']); | ||
|
||
expect(actual.all).toEqual([ | ||
mockListLogLine('two', { b: DiffNameStatus.RENAMED }), | ||
mockListLogLine('one', { a: DiffNameStatus.ADDED }), | ||
]); | ||
}); | ||
}); | ||
|
||
function mockListLogLine(message: string, changes: Record<string, DiffNameStatus>) { | ||
const files: DiffResultTextFile[] = Object.entries(changes).map(([file, status]) => { | ||
return { | ||
binary: false, | ||
changes: 0, | ||
deletions: 0, | ||
file, | ||
insertions: 0, | ||
status, | ||
}; | ||
}); | ||
return like({ | ||
message, | ||
diff: like({ changed: files.length, deletions: 0, insertions: 0, files }), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters