mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
GitHub - link provider for various hovers (#237961)
* Initial implementation * Refactor code, add link to blame decoration * Add links to timeline hover * Saving my work * Update remote order for "Open on GitHub" action * Bug fixes * Add link provider for graph hover * Rename method
This commit is contained in:
@@ -12,6 +12,7 @@ import { Branch, LogOptions, Ref, RefType } from './api/git';
|
||||
import { emojify, ensureEmojis } from './emoji';
|
||||
import { Commit } from './git';
|
||||
import { OperationKind, OperationResult } from './operation';
|
||||
import { provideRemoteSourceLinks } from './remoteSource';
|
||||
|
||||
function toSourceControlHistoryItemRef(repository: Repository, ref: Ref): SourceControlHistoryItemRef {
|
||||
const rootUri = Uri.file(repository.root);
|
||||
@@ -264,22 +265,33 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
||||
|
||||
await ensureEmojis();
|
||||
|
||||
return commits.map(commit => {
|
||||
const historyItems: SourceControlHistoryItem[] = [];
|
||||
for (const commit of commits) {
|
||||
const message = emojify(commit.message);
|
||||
const messageWithLinks = await provideRemoteSourceLinks(this.repository, message) ?? message;
|
||||
|
||||
const newLineIndex = message.indexOf('\n');
|
||||
const subject = newLineIndex !== -1
|
||||
? `${message.substring(0, newLineIndex)}\u2026`
|
||||
: message;
|
||||
|
||||
const references = this._resolveHistoryItemRefs(commit);
|
||||
|
||||
return {
|
||||
historyItems.push({
|
||||
id: commit.hash,
|
||||
parentIds: commit.parents,
|
||||
message: emojify(commit.message),
|
||||
subject,
|
||||
message: messageWithLinks,
|
||||
author: commit.authorName,
|
||||
authorEmail: commit.authorEmail,
|
||||
icon: new ThemeIcon('git-commit'),
|
||||
displayId: getCommitShortHash(Uri.file(this.repository.root), commit.hash),
|
||||
timestamp: commit.authorDate?.getTime(),
|
||||
statistics: commit.shortStat ?? { files: 0, insertions: 0, deletions: 0 },
|
||||
references: references.length !== 0 ? references : undefined
|
||||
};
|
||||
});
|
||||
} satisfies SourceControlHistoryItem);
|
||||
}
|
||||
|
||||
return historyItems;
|
||||
} catch (err) {
|
||||
this.logger.error(`[GitHistoryProvider][provideHistoryItems] Failed to get history items with options '${JSON.stringify(options)}': ${err}`);
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user