55
66import * as vscode from 'vscode' ;
77import { Change , Commit } from '../api/api' ;
8+ import { Disposable } from '../common/lifecycle' ;
89import Logger from '../common/logger' ;
910import { OctokitCommon } from '../github/common' ;
1011import { FolderRepositoryManager } from '../github/folderRepositoryManager' ;
@@ -18,7 +19,7 @@ export interface CreateModelChangeEvent {
1819 compareBranch ?: string ;
1920}
2021
21- export class CreatePullRequestDataModel {
22+ export class CreatePullRequestDataModel extends Disposable {
2223 private static ID = 'CreatePullRequestDataModel' ;
2324 private _baseOwner : string ;
2425 private _baseBranch : string ;
@@ -41,6 +42,7 @@ export class CreatePullRequestDataModel {
4142 private _gitcontentProvider : GitContentProvider ;
4243
4344 constructor ( private readonly folderRepositoryManager : FolderRepositoryManager , baseOwner : string , baseBranch : string , compareOwner : string , compareBranch : string , public readonly repositoryName : string ) {
45+ super ( ) ;
4446 this . _baseOwner = baseOwner ;
4547 this . _baseBranch = baseBranch ;
4648 this . _compareBranch = baseBranch ;
@@ -49,6 +51,12 @@ export class CreatePullRequestDataModel {
4951 this . _gitHubcontentProvider = new GitHubContentProvider ( this . folderRepositoryManager . gitHubRepositories ) ;
5052 this . _constructed = new Promise < void > ( resolve => this . setCompareBranch ( compareBranch ) . then ( resolve ) ) ;
5153 this . compareOwner = compareOwner ;
54+ this . _register ( folderRepositoryManager . repository . state . onDidChange ( ( ) => {
55+ if ( folderRepositoryManager . repository . state . HEAD ?. name === this . _compareBranch ) {
56+ // We assume that the commit has changed.
57+ this . update ( { } ) ;
58+ }
59+ } ) ) ;
5260 }
5361
5462 get gitHubContentProvider ( ) : GitHubContentProvider {
0 commit comments