Skip to content

Commit

Permalink
fix: commit list item description not shown
Browse files Browse the repository at this point in the history
  • Loading branch information
conwnet committed May 25, 2022
1 parent f769d39 commit 06b1e71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extensions/github1s/src/views/code-review-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const statusIconMap = {

export const getCodeReviewTreeItemLabel = (codeReview: adapterTypes.CodeReview) => {
const statusIcon = statusIconMap[getCodeReviewStatus(codeReview)];
return `${statusIcon} #${codeReview.id} ${codeReview.title}`;
return `${statusIcon} #${codeReview.id} ${codeReview.title.split(/[\r\n]/)[0]}`;
};

export const getCodeReviewTreeItemDescription = (codeReview: adapterTypes.CodeReview) => {
Expand Down
8 changes: 5 additions & 3 deletions extensions/github1s/src/views/commit-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import { getChangedFileDiffCommand, getCommitChangedFiles } from '@/changes/file
import { GitHub1sSourceControlDecorationProvider } from '@/providers/decorations/source-control';

export const getCommitTreeItemDescription = (commit: adapterTypes.Commit): string => {
return [commit.sha.slice(0, 7), commit.author, relativeTimeTo(commit.createTime)].join(', ');
const shortCommitSha = commit.sha.slice(0, 7);
const relativeTimeStr = commit.createTime ? relativeTimeTo(commit.createTime) : null;
return [shortCommitSha, commit.author, relativeTimeStr].filter(Boolean).join(', ');
};

export interface CommitTreeItem extends vscode.TreeItem {
Expand Down Expand Up @@ -91,9 +93,9 @@ export class CommitTreeDataProvider implements vscode.TreeDataProvider<vscode.Tr
const repository = Repository.getInstance(currentAdapter.scheme, repo);
const repositoryCommits = await repository.getCommitList(ref, filePath, this._forceUpdate);
const commitTreeItems = repositoryCommits.map((commit) => {
const label = `${commit.message}`;
const label = commit.message.split(/[\r\n]/)[0];
const description = getCommitTreeItemDescription(commit);
const tooltip = `${label} (${description})`;
const tooltip = `${commit.message}\n(${description})`;
const iconPath = vscode.Uri.parse(commit.avatarUrl || '');
const contextValue = 'github1s:viewItems:commitListItem';

Expand Down

0 comments on commit 06b1e71

Please sign in to comment.