@@ -17,6 +17,7 @@ import { IResolvedPullRequestModel, PullRequestModel } from './pullRequestModel'
1717const PullRequestRemoteMetadataKey = 'github-pr-remote' ;
1818export const PullRequestMetadataKey = 'github-pr-owner-number' ;
1919const BaseBranchMetadataKey = 'github-pr-base-branch' ;
20+ const VscodeBaseBranchMetadataKey = 'vscode-merge-base' ;
2021const PullRequestBranchRegex = / b r a n c h \. ( .+ ) \. g i t h u b - p r - o w n e r - n u m b e r / ;
2122const PullRequestRemoteRegex = / b r a n c h \. ( .+ ) \. r e m o t e / ;
2223
@@ -389,7 +390,11 @@ export class PullRequestGitHelper {
389390 Logger . appendLine ( `associate ${ branchName } with Pull Request #${ pullRequest . number } ` , PullRequestGitHelper . ID ) ;
390391 }
391392 const prConfigKey = `branch.${ branchName } .${ PullRequestMetadataKey } ` ;
392- await repository . setConfig ( prConfigKey , pullRequest ? PullRequestGitHelper . buildPullRequestMetadata ( pullRequest ) : ' ' ) ;
393+ if ( pullRequest ) {
394+ await repository . setConfig ( prConfigKey , PullRequestGitHelper . buildPullRequestMetadata ( pullRequest ) ) ;
395+ } else if ( repository . unsetConfig ) {
396+ await repository . unsetConfig ( prConfigKey ) ;
397+ }
393398 } catch ( e ) {
394399 if ( pullRequest ) {
395400 Logger . error ( `associate ${ branchName } with Pull Request #${ pullRequest . number } failed` , PullRequestGitHelper . ID ) ;
@@ -400,16 +405,24 @@ export class PullRequestGitHelper {
400405 static async associateBaseBranchWithBranch (
401406 repository : Repository ,
402407 branch : string ,
403- owner : string ,
404- repo : string ,
405- baseBranch : string
408+ base : {
409+ owner : string ,
410+ repo : string ,
411+ branch : string
412+ } | undefined
406413 ) {
407414 try {
408- Logger . appendLine ( `associate ${ branch } with base branch ${ owner } /${ repo } #${ baseBranch } ` , PullRequestGitHelper . ID ) ;
409415 const prConfigKey = `branch.${ branch } .${ BaseBranchMetadataKey } ` ;
410- await repository . setConfig ( prConfigKey , PullRequestGitHelper . buildBaseBranchMetadata ( owner , repo , baseBranch ) ) ;
416+ if ( base ) {
417+ Logger . appendLine ( `associate ${ branch } with base branch ${ base . owner } /${ base . repo } #${ base . branch } ` , PullRequestGitHelper . ID ) ;
418+ await repository . setConfig ( prConfigKey , PullRequestGitHelper . buildBaseBranchMetadata ( base . owner , base . repo , base . branch ) ) ;
419+ } else if ( repository . unsetConfig ) {
420+ await repository . unsetConfig ( prConfigKey ) ;
421+ const vscodeBaseBranchConfigKey = `branch.${ branch } .${ VscodeBaseBranchMetadataKey } ` ;
422+ await repository . unsetConfig ( vscodeBaseBranchConfigKey ) ;
423+ }
411424 } catch ( e ) {
412- Logger . error ( `associate ${ branch } with base branch ${ owner } /${ repo } #${ baseBranch } failed` , PullRequestGitHelper . ID ) ;
425+ Logger . error ( `associate ${ branch } with base branch ${ base ?. owner } /${ base ?. repo } #${ base ?. branch } failed` , PullRequestGitHelper . ID ) ;
413426 }
414427 }
415428}
0 commit comments