* A parser to read and emit cherry pick progress from Git `stdout`. * * Each successful cherry picked commit outputs a set of lines similar to the * following example: * [branchName commitSha] commitSummary * Date: timestamp * 1 file changed, 1 insertion(+) * create mode 100
| 71 | * create mode 100644 filename |
| 72 | */ |
| 73 | class GitCherryPickParser { |
| 74 | public constructor( |
| 75 | private readonly commits: ReadonlyArray<CommitOneLine>, |
| 76 | private count: number = 0 |
| 77 | ) {} |
| 78 | |
| 79 | public parse(line: string): IMultiCommitOperationProgress | null { |
| 80 | const cherryPickRe = /^\[(.*\s.*)\]/ |
| 81 | const match = cherryPickRe.exec(line) |
| 82 | if (match === null) { |
| 83 | // Skip lines that don't represent the first line of a successfully picked |
| 84 | // commit. -- i.e. timestamp, files changed, conflicts, etc.. |
| 85 | return null |
| 86 | } |
| 87 | this.count++ |
| 88 | |
| 89 | return { |
| 90 | kind: 'multiCommitOperation', |
| 91 | value: round(this.count / this.commits.length, 2), |
| 92 | position: this.count, |
| 93 | totalCommitCount: this.commits.length, |
| 94 | currentCommitSummary: this.commits[this.count - 1]?.summary ?? '', |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * This method merges `baseOptions` with a call back method that obtains a |
nothing calls this directly
no outgoing calls
no test coverage detected