mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
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:
@@ -3,10 +3,8 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Command } from 'vscode';
|
||||
import { PickRemoteSourceOptions, PickRemoteSourceResult } from './typings/git-base';
|
||||
import { GitBaseApi } from './git-base';
|
||||
import { Repository } from './repository';
|
||||
|
||||
export async function pickRemoteSource(options: PickRemoteSourceOptions & { branch?: false | undefined }): Promise<string | undefined>;
|
||||
export async function pickRemoteSource(options: PickRemoteSourceOptions & { branch: true }): Promise<PickRemoteSourceResult | undefined>;
|
||||
@@ -17,36 +15,3 @@ export async function pickRemoteSource(options: PickRemoteSourceOptions = {}): P
|
||||
export async function getRemoteSourceActions(url: string) {
|
||||
return GitBaseApi.getAPI().getRemoteSourceActions(url);
|
||||
}
|
||||
|
||||
export async function getRemoteSourceControlHistoryItemCommands(repository: Repository): Promise<Command[]> {
|
||||
if (repository.remotes.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const getCommands = async (repository: Repository, remoteName: string): Promise<Command[] | undefined> => {
|
||||
const remote = repository.remotes.find(r => r.name === remoteName && r.fetchUrl);
|
||||
return remote ? GitBaseApi.getAPI().getRemoteSourceControlHistoryItemCommands(remote.fetchUrl!) : undefined;
|
||||
};
|
||||
|
||||
// upstream -> origin -> first
|
||||
return await getCommands(repository, 'upstream')
|
||||
?? await getCommands(repository, 'origin')
|
||||
?? await getCommands(repository, repository.remotes[0].name)
|
||||
?? [];
|
||||
}
|
||||
|
||||
export async function provideRemoteSourceLinks(repository: Repository, content: string): Promise<string | undefined> {
|
||||
if (repository.remotes.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const getDocumentLinks = async (repository: Repository, remoteName: string): Promise<string | undefined> => {
|
||||
const remote = repository.remotes.find(r => r.name === remoteName && r.fetchUrl);
|
||||
return remote ? GitBaseApi.getAPI().provideRemoteSourceLinks(remote.fetchUrl!, content) : undefined;
|
||||
};
|
||||
|
||||
// upstream -> origin -> first
|
||||
return await getDocumentLinks(repository, 'upstream')
|
||||
?? await getDocumentLinks(repository, 'origin')
|
||||
?? await getDocumentLinks(repository, repository.remotes[0].name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user