(flags: string[])
| 45 | } |
| 46 | |
| 47 | export function flagsToGitDiffOptions(flags: string[]): Partial<GitDiffOptions> { |
| 48 | const options: Partial<GitDiffOptions> = {}; |
| 49 | for (const flag of flags) { |
| 50 | if (flag == '-w' || flag == '--ignore-all-space') { |
| 51 | options.ignoreAllSpace = true; |
| 52 | } else if (flag == '-b' || flag == '--ignore-space-change') { |
| 53 | options.ignoreSpaceChange = true; |
| 54 | } else if (flag == '-W' || flag == '--function-context') { |
| 55 | options.functionContext = true; |
| 56 | } else if (flag.startsWith('--diff-algorithm=')) { |
| 57 | // This is pretty imprecise; I believe `--diff-algorithm patience` would also work. |
| 58 | const algo = flag.split('=')[1]; |
| 59 | options.diffAlgorithm = algo as DiffAlgorithm; |
| 60 | } else if (flag.startsWith('-U')) { |
| 61 | options.unified = Number(flag.slice(2)); |
| 62 | } |
| 63 | } |
| 64 | return options; |
| 65 | } |
no outgoing calls
no test coverage detected