|
8 | 8 | SourceControlInputBox, |
9 | 9 | Disposable, |
10 | 10 | EventEmitter, |
11 | | - Event |
| 11 | + Event, |
| 12 | + window |
12 | 13 | } from "vscode"; |
13 | 14 | import { Resource } from "./resource"; |
14 | 15 | import { throttle, debounce } from "./decorators"; |
@@ -112,8 +113,12 @@ export class Repository { |
112 | 113 | this.changes.hideWhenEmpty = true; |
113 | 114 | this.notTracked.hideWhenEmpty = true; |
114 | 115 |
|
115 | | - this.disposables.push(toDisposable(() => clearInterval(this.branchesTimer))); |
116 | | - setInterval(() => {this.updateBranches()}, 1000 * 60 * 5); // 5 minutes |
| 116 | + this.disposables.push( |
| 117 | + toDisposable(() => clearInterval(this.branchesTimer)) |
| 118 | + ); |
| 119 | + setInterval(() => { |
| 120 | + this.updateBranches(); |
| 121 | + }, 1000 * 60 * 5); // 5 minutes |
117 | 122 |
|
118 | 123 | this.updateBranches(); |
119 | 124 | this.update(); |
@@ -209,10 +214,22 @@ export class Repository { |
209 | 214 | async switchBranch(name: string) { |
210 | 215 | this.isSwitchingBranch = true; |
211 | 216 | this._onDidChangeRepository.fire(); |
212 | | - const response = await this.repository.switchBranch(name); |
213 | | - this.isSwitchingBranch = false; |
214 | | - this.updateBranches(); |
215 | | - this._onDidChangeRepository.fire(); |
216 | | - return response; |
| 217 | + |
| 218 | + try { |
| 219 | + const response = await this.repository.switchBranch(name); |
| 220 | + } catch (error) { |
| 221 | + if (/E195012/.test(error)) { |
| 222 | + window.showErrorMessage( |
| 223 | + "Path '.' does not share common version control ancestry with the requested switch location." |
| 224 | + ); |
| 225 | + return; |
| 226 | + } |
| 227 | + |
| 228 | + window.showErrorMessage("Unable to switch branch"); |
| 229 | + } finally { |
| 230 | + this.isSwitchingBranch = false; |
| 231 | + this.updateBranches(); |
| 232 | + this._onDidChangeRepository.fire(); |
| 233 | + } |
217 | 234 | } |
218 | 235 | } |
0 commit comments