(line: string)
| 201 | } |
| 202 | |
| 203 | function createLine(line: string): void { |
| 204 | if (currentFile === null || currentBlock === null || oldLine === null || newLine === null) return; |
| 205 | |
| 206 | // eslint-disable-next-line |
| 207 | // @ts-ignore |
| 208 | const currentLine: DiffLine = { |
| 209 | content: line, |
| 210 | }; |
| 211 | |
| 212 | const addedPrefixes = currentFile.isCombined ? ['+ ', ' +', '++'] : ['+']; |
| 213 | const deletedPrefixes = currentFile.isCombined ? ['- ', ' -', '--'] : ['-']; |
| 214 | |
| 215 | if (startsWithAny(line, addedPrefixes)) { |
| 216 | currentFile.addedLines++; |
| 217 | currentLine.type = LineType.INSERT; |
| 218 | currentLine.oldNumber = undefined; |
| 219 | currentLine.newNumber = newLine++; |
| 220 | } else if (startsWithAny(line, deletedPrefixes)) { |
| 221 | currentFile.deletedLines++; |
| 222 | currentLine.type = LineType.DELETE; |
| 223 | currentLine.oldNumber = oldLine++; |
| 224 | currentLine.newNumber = undefined; |
| 225 | } else { |
| 226 | currentLine.type = LineType.CONTEXT; |
| 227 | currentLine.oldNumber = oldLine++; |
| 228 | currentLine.newNumber = newLine++; |
| 229 | } |
| 230 | currentBlock.lines.push(currentLine); |
| 231 | } |
| 232 | |
| 233 | /* |
| 234 | * Checks if there is a hunk header coming before a new file starts |
no test coverage detected
searching dependent graphs…