Skip to content

Commit

Permalink
Files changed doesn't properly reflect changes against non base branch
Browse files Browse the repository at this point in the history
Fixes #5545
  • Loading branch information
alexr00 committed Dec 12, 2023
1 parent 3e18a16 commit de73656
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/view/createPullRequestDataModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,31 @@ export class CreatePullRequestDataModel {
public async gitCommits(): Promise<Commit[]> {
await this._constructed;
if (this._gitLog === undefined) {
this._gitLog = this.folderRepositoryManager.repository.log({ range: `${this._baseBranch}..${this._compareBranch}` });
const startBase = this._baseBranch;
const startCompare = this._compareBranch;
const result = this.folderRepositoryManager.repository.log({ range: `${this._baseBranch}..${this._compareBranch}` });
if (startBase !== this._baseBranch || startCompare !== this._compareBranch) {
// The branches have changed while we were waiting for the log. We can use the result, but we shouldn't save it
return result;
} else {
this._gitLog = result;
}
}
return this._gitLog;
}

public async gitFiles(): Promise<Change[]> {
await this._constructed;
if (this._gitFiles === undefined) {
this._gitFiles = await this.folderRepositoryManager.repository.diffBetween(this._baseBranch, this._compareBranch);
const startBase = this._baseBranch;
const startCompare = this._compareBranch;
const result = await this.folderRepositoryManager.repository.diffBetween(this._baseBranch, this._compareBranch);
if (startBase !== this._baseBranch || startCompare !== this._compareBranch) {
// The branches have changed while we were waiting for the diff. We can use the result, but we shouldn't save it
return result;
} else {
this._gitFiles = result;
}
}
return this._gitFiles;
}
Expand Down

0 comments on commit de73656

Please sign in to comment.