* Creates a commit with the given message. Optionally, an id can be specified to * associate the created commit with a shortcut in order to reference it conveniently * when writing tests (e.g. when cherry-picking later).
(message: string, id?: number)
| 45 | * when writing tests (e.g. when cherry-picking later). |
| 46 | */ |
| 47 | commit(message: string, id?: number): this { |
| 48 | // Capture existing files in the temporary directory. e.g. if a changelog |
| 49 | // file has been written before we want to preserve that in the fake repo. |
| 50 | runGitInTmpDir(['add', '-A']); |
| 51 | runGitInTmpDir(['commit', '--allow-empty', '-m', message]); |
| 52 | |
| 53 | if (id !== undefined) { |
| 54 | const commitSha = runGitInTmpDir(['rev-parse', 'HEAD']); |
| 55 | this._commitShaById.set(id, commitSha); |
| 56 | } |
| 57 | |
| 58 | return this; |
| 59 | } |
| 60 | |
| 61 | /** Branches off the current repository `HEAD`. */ |
| 62 | branchOff(newBranchName: string): this { |
no test coverage detected