From 88de40c1dff3af131ad71131ee7560043697d89a Mon Sep 17 00:00:00 2001 From: Felix Kling Date: Wed, 22 May 2024 12:53:03 +0200 Subject: [PATCH] svelte: Show correct byline when commit has author and committer (#62841) It was reported that the "byline" isn't correct when a commit has an author and a committer. This fixes it. --- client/web-sveltekit/src/lib/Commit.gql | 1 + client/web-sveltekit/src/lib/Commit.svelte | 27 +++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/client/web-sveltekit/src/lib/Commit.gql b/client/web-sveltekit/src/lib/Commit.gql index 6eacf054ad8..24e77109650 100644 --- a/client/web-sveltekit/src/lib/Commit.gql +++ b/client/web-sveltekit/src/lib/Commit.gql @@ -8,6 +8,7 @@ fragment Commit on GitCommit { date person { name + email ...Avatar_Person } } diff --git a/client/web-sveltekit/src/lib/Commit.svelte b/client/web-sveltekit/src/lib/Commit.svelte index b92847a44c1..5f82b30b8eb 100644 --- a/client/web-sveltekit/src/lib/Commit.svelte +++ b/client/web-sveltekit/src/lib/Commit.svelte @@ -13,7 +13,7 @@ export let commit: Commit export let alwaysExpanded: boolean = false - function getCommitter({ committer }: Commit): NonNullable['person'] | null { + function getCommitter({ committer }: Commit): NonNullable | null { if (!committer) { return null } @@ -21,26 +21,27 @@ if (committer.person.name === 'GitHub' && committer.person.email === 'noreply@github.com') { return null } - return committer.person + return committer } - $: commitDate = new Date(commit.committer ? commit.committer.date : commit.author.date) - $: author = commit.author.person - $: committer = getCommitter(commit) - $: authorAvatarTooltip = author.name + (committer ? ' (author)' : '') + $: author = commit.author + $: committer = getCommitter(commit) ?? author + $: committerIsAuthor = committer.person.email === author.person.email + $: commitDate = new Date(committer.date) + $: authorAvatarTooltip = author.person.name + (committer ? ' (author)' : '') let expanded = alwaysExpanded
- +
- {#if committer && committer.name !== author.name} + {#if !committerIsAuthor}
- - + +
{/if} @@ -53,7 +54,11 @@ {/if} - committed by {author.name} + + {#if !committerIsAuthor}authored by {author.person.name} and{/if} + committed by {committer.person.name} + + {#if expanded && commit.body}
{commit.body}
{/if}