(fileName: string | undefined)
| 1 | import type { StructuredPatch } from '../types.js'; |
| 2 | |
| 3 | function swapPrefix(fileName: string | undefined): string | undefined { |
| 4 | if (fileName === undefined || fileName === '/dev/null') { |
| 5 | return fileName; |
| 6 | } |
| 7 | if (fileName.startsWith('a/')) { |
| 8 | return 'b/' + fileName.slice(2); |
| 9 | } |
| 10 | if (fileName.startsWith('b/')) { |
| 11 | return 'a/' + fileName.slice(2); |
| 12 | } |
| 13 | return fileName; |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Returns a new structured patch which when applied will undo the original `patch`. |