@@ -357,23 +357,27 @@ export class ReviewManager extends Disposable {
357357 }
358358
359359 private async checkGitHubForPrBranch ( branch : Branch ) : Promise < ( PullRequestMetadata & { model : PullRequestModel } ) | undefined > {
360-
361- let branchToCheck : Branch ;
362- if ( this . _repository . state . HEAD && ( branch . name === this . _repository . state . HEAD . name ) ) {
363- branchToCheck = this . _repository . state . HEAD ;
364- } else {
365- branchToCheck = branch ;
366- }
367- const { remoteUrl : url , upstreamBranchName, remoteName } = await this . getUpstreamUrlAndName ( branchToCheck ) ;
368- const metadataFromGithub = await this . _folderRepoManager . getMatchingPullRequestMetadataFromGitHub ( branchToCheck , remoteName , url , upstreamBranchName ) ;
369- if ( metadataFromGithub ) {
370- Logger . appendLine ( `Found matching pull request metadata on GitHub for current branch ${ branch . name } . Repo: ${ metadataFromGithub . owner } /${ metadataFromGithub . repositoryName } PR: ${ metadataFromGithub . prNumber } ` , this . id ) ;
371- await PullRequestGitHelper . associateBranchWithPullRequest (
372- this . _repository ,
373- metadataFromGithub . model ,
374- branch . name ! ,
375- ) ;
376- return metadataFromGithub ;
360+ try {
361+ let branchToCheck : Branch ;
362+ if ( this . _repository . state . HEAD && ( branch . name === this . _repository . state . HEAD . name ) ) {
363+ branchToCheck = this . _repository . state . HEAD ;
364+ } else {
365+ branchToCheck = branch ;
366+ }
367+ const { remoteUrl : url , upstreamBranchName, remoteName } = await this . getUpstreamUrlAndName ( branchToCheck ) ;
368+ const metadataFromGithub = await this . _folderRepoManager . getMatchingPullRequestMetadataFromGitHub ( branchToCheck , remoteName , url , upstreamBranchName ) ;
369+ if ( metadataFromGithub ) {
370+ Logger . appendLine ( `Found matching pull request metadata on GitHub for current branch ${ branch . name } . Repo: ${ metadataFromGithub . owner } /${ metadataFromGithub . repositoryName } PR: ${ metadataFromGithub . prNumber } ` , this . id ) ;
371+ await PullRequestGitHelper . associateBranchWithPullRequest (
372+ this . _repository ,
373+ metadataFromGithub . model ,
374+ branch . name ! ,
375+ ) ;
376+ return metadataFromGithub ;
377+ }
378+ } catch ( e ) {
379+ Logger . warn ( `Failed to check GitHub for PR branch: ${ e . message } ` , this . id ) ;
380+ return undefined ;
377381 }
378382 }
379383
@@ -441,13 +445,6 @@ export class ReviewManager extends Disposable {
441445 }
442446 Logger . appendLine ( `Found matching pull request metadata for current branch ${ branch . name } . Repo: ${ matchingPullRequestMetadata . owner } /${ matchingPullRequestMetadata . repositoryName } PR: ${ matchingPullRequestMetadata . prNumber } ` , this . id ) ;
443447
444- const remote = branch . upstream ? branch . upstream . remote : null ;
445- if ( ! remote ) {
446- Logger . appendLine ( `Current branch ${ this . _repository . state . HEAD . name } hasn't setup remote yet` , this . id ) ;
447- await this . clear ( true ) ;
448- return ;
449- }
450-
451448 // we switch to another PR, let's clean up first.
452449 Logger . appendLine (
453450 `current branch ${ this . _repository . state . HEAD . name } is associated with pull request #${ matchingPullRequestMetadata . prNumber } ` , this . id
0 commit comments