* Checks out a requested branch or revision, optionally cleaning the state of the repository * before attempting the checking. Returns a boolean indicating whether the branch or revision * was cleanly checked out.
(branchOrRevision: string, cleanState: boolean)
| 182 | * was cleanly checked out. |
| 183 | */ |
| 184 | checkout(branchOrRevision: string, cleanState: boolean): boolean { |
| 185 | assertValidGitRef(branchOrRevision); |
| 186 | if (cleanState) { |
| 187 | // Abort any outstanding ams. |
| 188 | this.runGraceful(['am', '--abort'], {stdio: 'ignore'}); |
| 189 | // Abort any outstanding cherry-picks. |
| 190 | this.runGraceful(['cherry-pick', '--abort'], {stdio: 'ignore'}); |
| 191 | // Abort any outstanding rebases. |
| 192 | this.runGraceful(['rebase', '--abort'], {stdio: 'ignore'}); |
| 193 | // Clear any changes in the current repo. |
| 194 | this.runGraceful(['reset', '--hard'], {stdio: 'ignore'}); |
| 195 | } |
| 196 | return this.runGraceful(['checkout', branchOrRevision], {stdio: 'ignore'}).status === 0; |
| 197 | } |
| 198 | |
| 199 | /** Retrieve a list of all files in the repository changed since the provided shaOrRef. */ |
| 200 | allChangesFilesSince(shaOrRef = 'HEAD'): string[] { |
no test coverage detected