Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/test/view/reviewCommentController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('ReviewCommentController', function () {
let githubRepo: MockGitHubRepository;
let reviewManager: ReviewManager;
let reposManager: RepositoriesManager;
let gitApiImpl: GitApiImpl;

beforeEach(async function () {
sinon = createSandbox();
Expand All @@ -75,7 +76,7 @@ describe('ReviewCommentController', function () {
const activePrViewCoordinator = new WebviewViewCoordinator(context);
const createPrHelper = new CreatePullRequestHelper();
Resource.initialize(context);
const gitApiImpl = new GitApiImpl();
gitApiImpl = new GitApiImpl();
manager = new FolderRepositoryManager(0, context, repository, telemetry, gitApiImpl, credentialStore);
reposManager.insertFolderManager(manager);
const tree = new PullRequestChangesTreeDataProvider(context, gitApiImpl, reposManager);
Expand Down Expand Up @@ -169,7 +170,7 @@ describe('ReviewCommentController', function () {
const localFileChanges = [createLocalFileChange(uri, fileName, repository.rootUri)];
const reviewModel = new ReviewModel();
reviewModel.localFileChanges = localFileChanges;
const reviewCommentController = new TestReviewCommentController(reviewManager, manager, repository, reviewModel);
const reviewCommentController = new TestReviewCommentController(reviewManager, manager, repository, reviewModel, gitApiImpl);

sinon.stub(activePullRequest, 'validateDraftMode').returns(Promise.resolve(false));
sinon.stub(activePullRequest, 'getReviewThreads').returns(
Expand Down Expand Up @@ -234,6 +235,7 @@ describe('ReviewCommentController', function () {
manager,
repository,
reviewModel,
gitApiImpl
);
const thread = createGHPRCommentThread('review-1.1', uri);

Expand Down
6 changes: 5 additions & 1 deletion src/view/reviewCommentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as nodePath from 'path';
import { v4 as uuid } from 'uuid';
import * as vscode from 'vscode';
import { Repository } from '../api/api';
import { GitApiImpl } from '../api/api1';
import { CommentHandler, registerCommentHandler, unregisterCommentHandler } from '../commentHandlerResolver';
import { DiffSide, IReviewThread, SubjectType } from '../common/comment';
import { getCommentingRanges } from '../common/commentingRanges';
Expand All @@ -22,6 +23,7 @@ import { PullRequestOverviewPanel } from '../github/pullRequestOverview';
import {
CommentReactionHandler,
createVSCodeCommentThreadForReviewThread,
getRepositoryForFile,
isFileInRepo,
threadRange,
updateCommentReviewState,
Expand Down Expand Up @@ -57,6 +59,7 @@ export class ReviewCommentController extends CommentControllerBase
folderRepoManager: FolderRepositoryManager,
private _repository: Repository,
private _reviewModel: ReviewModel,
private _gitApi: GitApiImpl
) {
super(folderRepoManager);
this._context = this._folderRepoManager.context;
Expand Down Expand Up @@ -443,7 +446,8 @@ export class ReviewCommentController extends CommentControllerBase
}
}

if (!isFileInRepo(this._repository, document.uri)) {
const bestRepoForFile = getRepositoryForFile(this._gitApi, document.uri);
if (bestRepoForFile?.rootUri.toString() !== this._repository.rootUri.toString()) {
if (document.uri.scheme !== 'output') {
Logger.debug('No commenting ranges: File is not in the current repository.', ReviewCommentController.ID);
}
Expand Down
5 changes: 3 additions & 2 deletions src/view/reviewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class ReviewManager {
private _showPullRequest: ShowPullRequest,
private readonly _activePrViewCoordinator: WebviewViewCoordinator,
private _createPullRequestHelper: CreatePullRequestHelper,
gitApi: GitApiImpl
private _gitApi: GitApiImpl
) {
this._switchingToReviewMode = false;
this._disposables = [];
Expand All @@ -115,7 +115,7 @@ export class ReviewManager {

this.registerListeners();

if (gitApi.state === 'initialized') {
if (_gitApi.state === 'initialized') {
this.updateState(true);
}
this.pollForStatusChange();
Expand Down Expand Up @@ -906,6 +906,7 @@ export class ReviewManager {
this._folderRepoManager,
this._repository,
this._reviewModel,
this._gitApi
);

await this._reviewCommentController.initialize();
Expand Down