- Updated the Editor and EditorTabs components to improve file path handling for diffs, including support for commit and stash references. - Added new translations for Git-related messages in English and Chinese. - Introduced methods in GitService to retrieve changed files for commits and stashes, enhancing the ability to display file changes. - Implemented a utility to parse `git --name-status` output for structured file change representation. - Added unit tests for the new parsing utility to ensure accuracy and reliability and fix #159.
26 lines
756 B
TypeScript
26 lines
756 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { parseGitNameStatus } from '@/shared/utils/gitNameStatus'
|
|
|
|
describe('parseGitNameStatus', () => {
|
|
it('parses added/modified/deleted entries', () => {
|
|
const result = parseGitNameStatus([
|
|
'M\tsrc/a.ts',
|
|
'A\tsrc/b.ts',
|
|
'D\tsrc/c.ts',
|
|
].join('\n'))
|
|
|
|
expect(result).toEqual([
|
|
{ status: 'modified', path: 'src/a.ts' },
|
|
{ status: 'added', path: 'src/b.ts' },
|
|
{ status: 'deleted', path: 'src/c.ts' },
|
|
])
|
|
})
|
|
|
|
it('parses renames with old and new paths', () => {
|
|
const result = parseGitNameStatus('R100\told/name.ts\tnew/name.ts\n')
|
|
expect(result).toEqual([
|
|
{ status: 'renamed', oldPath: 'old/name.ts', path: 'new/name.ts' },
|
|
])
|
|
})
|
|
})
|