|
|
@ -10,9 +10,9 @@ import type { Container } from '../../container'; |
|
|
|
import { GitUri } from '../../git/gitUri'; |
|
|
|
import type { GitCommit } from '../../git/models/commit'; |
|
|
|
import { GitFile } from '../../git/models/file'; |
|
|
|
import type { IssueOrPullRequest } from '../../git/models/issue'; |
|
|
|
import { executeCommand, executeCoreCommand } from '../../system/command'; |
|
|
|
import { debug } from '../../system/decorators/log'; |
|
|
|
import { getSettledValue } from '../../system/promise'; |
|
|
|
import { IpcMessage, onIpc } from '../protocol'; |
|
|
|
import { WebviewViewBase } from '../webviewViewBase'; |
|
|
|
import { |
|
|
@ -29,7 +29,6 @@ import { |
|
|
|
PickCommitCommandType, |
|
|
|
RichCommitDetails, |
|
|
|
RichContentNotificationType, |
|
|
|
SearchCommitCommandType, |
|
|
|
State, |
|
|
|
} from './protocol'; |
|
|
|
|
|
|
@ -88,11 +87,6 @@ export class CommitDetailsWebviewView extends WebviewViewBase { |
|
|
|
this.showCommitPicker(); |
|
|
|
}); |
|
|
|
break; |
|
|
|
case SearchCommitCommandType.method: |
|
|
|
onIpc(SearchCommitCommandType, e, _params => { |
|
|
|
this.showCommitSearch(); |
|
|
|
}); |
|
|
|
break; |
|
|
|
case AutolinkSettingsCommandType.method: |
|
|
|
onIpc(AutolinkSettingsCommandType, e, _params => { |
|
|
|
this.showAutolinkSettings(); |
|
|
@ -200,57 +194,46 @@ export class CommitDetailsWebviewView extends WebviewViewBase { |
|
|
|
private copyRemoteFileUrl() {} |
|
|
|
|
|
|
|
private async getRichContent(selected: GitCommit): Promise<RichCommitDetails> { |
|
|
|
const pullRequest = selected != null ? await selected.getAssociatedPullRequest() : undefined; |
|
|
|
console.log('CommitDetailsWebview pullRequest', pullRequest); |
|
|
|
|
|
|
|
const issues: Record<string, any>[] = []; |
|
|
|
let formattedMessage; |
|
|
|
if (selected?.message !== undefined && typeof selected.message === 'string') { |
|
|
|
const remote = await this.container.git.getBestRemoteWithRichProvider(selected.repoPath); |
|
|
|
console.log('CommitDetailsWebview remote', remote); |
|
|
|
|
|
|
|
if (remote != null) { |
|
|
|
const issueSearch = await this.container.autolinks.getLinkedIssuesAndPullRequests( |
|
|
|
selected.message, |
|
|
|
remote, |
|
|
|
); |
|
|
|
// TODO: add HTML formatting option to linkify
|
|
|
|
// formattedMessage = this.container.autolinks.linkify(
|
|
|
|
// escapeMarkdown(selected.message, { quoted: true }),
|
|
|
|
// true,
|
|
|
|
// [remote],
|
|
|
|
// // issueSearch,
|
|
|
|
// );
|
|
|
|
formattedMessage = this.container.autolinks.linkify( |
|
|
|
encodeMarkup(selected.message), |
|
|
|
true, |
|
|
|
[remote], |
|
|
|
// issueSearch,
|
|
|
|
); |
|
|
|
|
|
|
|
let filteredIssues; |
|
|
|
if (issueSearch != null) { |
|
|
|
if (pullRequest !== undefined) { |
|
|
|
issueSearch.delete(pullRequest.id); |
|
|
|
} |
|
|
|
|
|
|
|
filteredIssues = Array.from(issueSearch.values()).filter( |
|
|
|
value => value != null, |
|
|
|
) as IssueOrPullRequest[]; |
|
|
|
} |
|
|
|
|
|
|
|
console.log('CommitDetailsWebview filteredIssues', filteredIssues); |
|
|
|
|
|
|
|
if (filteredIssues !== undefined) { |
|
|
|
issues.push(...filteredIssues); |
|
|
|
} |
|
|
|
} |
|
|
|
const remotes = await this.container.git.getRemotesWithProviders(selected.repoPath, { sort: true }); |
|
|
|
const remote = await this.container.git.getBestRemoteWithRichProvider(remotes); |
|
|
|
|
|
|
|
if (selected.message == null) { |
|
|
|
await selected.ensureFullDetails(); |
|
|
|
} |
|
|
|
|
|
|
|
let autolinkedIssuesOrPullRequests; |
|
|
|
let pr; |
|
|
|
|
|
|
|
if (remote?.provider != null) { |
|
|
|
const [autolinkedIssuesOrPullRequestsResult, prResult] = await Promise.allSettled([ |
|
|
|
this.container.autolinks.getLinkedIssuesAndPullRequests(selected.message ?? selected.summary, remote), |
|
|
|
selected.getAssociatedPullRequest({ remote: remote }), |
|
|
|
]); |
|
|
|
|
|
|
|
autolinkedIssuesOrPullRequests = getSettledValue(autolinkedIssuesOrPullRequestsResult); |
|
|
|
pr = getSettledValue(prResult); |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: add HTML formatting option to linkify
|
|
|
|
const formattedMessage = this.container.autolinks.linkify( |
|
|
|
encodeMarkup(selected.message!), |
|
|
|
true, |
|
|
|
remote != null ? [remote] : undefined, |
|
|
|
autolinkedIssuesOrPullRequests, |
|
|
|
); |
|
|
|
|
|
|
|
// Remove possible duplicate pull request
|
|
|
|
if (pr != null) { |
|
|
|
autolinkedIssuesOrPullRequests?.delete(pr.id); |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|
formattedMessage: formattedMessage, |
|
|
|
pullRequest: pullRequest, |
|
|
|
issues: issues?.length ? issues : undefined, |
|
|
|
pullRequest: pr, |
|
|
|
issues: |
|
|
|
autolinkedIssuesOrPullRequests != null |
|
|
|
? [...autolinkedIssuesOrPullRequests.values()].filter(<T>(i: T | undefined): i is T => i != null) |
|
|
|
: undefined, |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|