Git - extract history item detail provider (#238041)

* Initial refactor of hover commands

* Delete old code for hover commands

* More refactoring
This commit is contained in:
Ladislau Szomoru
2025-01-16 11:37:27 +01:00
committed by GitHub
parent 47cff90e28
commit eaba97f995
20 changed files with 182 additions and 150 deletions

View File

@@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Command, Uri, env, l10n, workspace } from 'vscode';
import { Uri, env, l10n, workspace } from 'vscode';
import { RemoteSourceProvider, RemoteSource, RemoteSourceAction } from './typings/git-base';
import { getOctokit } from './auth';
import { Octokit } from '@octokit/rest';
import { getRepositoryFromQuery, getRepositoryFromUrl, ISSUE_EXPRESSION } from './util';
import { getRepositoryFromQuery, getRepositoryFromUrl } from './util';
import { getBranchLink, getVscodeDevHost } from './links';
function asRemoteSource(raw: any): RemoteSource {
@@ -136,42 +136,4 @@ export class GithubRemoteSourceProvider implements RemoteSourceProvider {
}
}];
}
async getRemoteSourceControlHistoryItemCommands(url: string): Promise<Command[] | undefined> {
const repository = getRepositoryFromUrl(url);
if (!repository) {
return undefined;
}
return [{
title: l10n.t('{0} Open on GitHub', '$(github)'),
tooltip: l10n.t('Open on GitHub'),
command: 'github.openOnGitHub',
arguments: [url]
}];
}
provideRemoteSourceLinks(url: string, content: string): string | undefined {
const repository = getRepositoryFromUrl(url);
if (!repository) {
return undefined;
}
return content.replace(
ISSUE_EXPRESSION,
(match, _group1, owner: string | undefined, repo: string | undefined, _group2, number: string | undefined) => {
if (!number || Number.isNaN(parseInt(number))) {
return match;
}
const label = owner && repo
? `${owner}/${repo}#${number}`
: `#${number}`;
owner = owner ?? repository.owner;
repo = repo ?? repository.repo;
return `[${label}](https://github.com/${owner}/${repo}/issues/${number})`;
});
}
}