Skip to content

Commit a6b7b5b

Browse files
committed
more clean up
1 parent 85be169 commit a6b7b5b

3 files changed

Lines changed: 8 additions & 13 deletions

File tree

src/github/emptyCommitWebview.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import { EXTENSION_ID } from '../constants';
87

98
/**
109
* Opens a webview panel to display a message for an empty commit.
1110
* The message is centered and styled similar to GitHub.com.
1211
*/
13-
export function showEmptyCommitWebview(commitSha: string): void {
12+
export function showEmptyCommitWebview(extensionUri: vscode.Uri, commitSha: string): void {
1413
const panel = vscode.window.createWebviewPanel(
1514
'emptyCommit',
1615
vscode.l10n.t('Commit {0}', commitSha.substring(0, 7)),
@@ -21,14 +20,10 @@ export function showEmptyCommitWebview(commitSha: string): void {
2120
}
2221
);
2322

24-
// Set icon for the webview panel tab
25-
const extensionUri = vscode.extensions.getExtension(EXTENSION_ID)?.extensionUri;
26-
if (extensionUri) {
27-
panel.iconPath = {
28-
light: vscode.Uri.joinPath(extensionUri, 'resources', 'icons', 'codicons', 'git-commit.svg'),
29-
dark: vscode.Uri.joinPath(extensionUri, 'resources', 'icons', 'codicons', 'git-commit.svg')
30-
};
31-
}
23+
panel.iconPath = {
24+
light: vscode.Uri.joinPath(extensionUri, 'resources', 'icons', 'codicons', 'git-commit.svg'),
25+
dark: vscode.Uri.joinPath(extensionUri, 'resources', 'icons', 'codicons', 'git-commit.svg')
26+
};
3227

3328
panel.webview.html = getEmptyCommitHtml();
3429
}

src/github/pullRequestModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
14661466
return vscode.commands.executeCommand('vscode.changes', vscode.l10n.t('Changes in Pull Request #{0}', pullRequestModel.number), args);
14671467
}
14681468

1469-
static async openCommitChanges(githubRepository: GitHubRepository, commitSha: string) {
1469+
static async openCommitChanges(extensionUri: vscode.Uri, githubRepository: GitHubRepository, commitSha: string) {
14701470
try {
14711471
const parentCommit = await githubRepository.getCommitParent(commitSha);
14721472
if (!parentCommit) {
@@ -1477,7 +1477,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
14771477
const changes = await githubRepository.compareCommits(parentCommit, commitSha);
14781478
if (!changes?.files || changes.files.length === 0) {
14791479
// Show a webview with the empty commit message instead of a notification
1480-
showEmptyCommitWebview(commitSha);
1480+
showEmptyCommitWebview(extensionUri, commitSha);
14811481
return;
14821482
}
14831483

src/github/pullRequestOverview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
554554
private async openCommitChanges(message: IRequestMessage<OpenCommitChangesArgs>): Promise<void> {
555555
try {
556556
const { commitSha } = message.args;
557-
await PullRequestModel.openCommitChanges(this._item.githubRepository, commitSha);
557+
await PullRequestModel.openCommitChanges(this._extensionUri, this._item.githubRepository, commitSha);
558558
this._replyMessage(message, {});
559559
} catch (error) {
560560
Logger.error(`Failed to open commit changes: ${formatError(error)}`, PullRequestOverviewPanel.ID);

0 commit comments

Comments
 (0)