fix: add parentheses to fix operator precedence in co-author check (#1199)

`??` has lower precedence than `!==`, so the expression:
  triggerDisplayName ?? triggerUsername !== "Unknown"
parses as:
  triggerDisplayName ?? (triggerUsername !== "Unknown")

When triggerDisplayName is an empty string "", the condition
evaluates to "" (falsy), incorrectly skipping the co-author line
even though the user is not "Unknown".

Add parentheses to get the intended behavior:
  (triggerDisplayName ?? triggerUsername) !== "Unknown"

Co-authored-by: Rush <rush@RushdeMacBook-Pro.local>
This commit is contained in:
Futurize Rush 2026-05-15 07:58:17 +08:00 committed by GitHub
parent 51ea8ea73a
commit bbad5183ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -395,7 +395,7 @@ function getCommitInstructions(
useCommitSigning: boolean, useCommitSigning: boolean,
): string { ): string {
const coAuthorLine = const coAuthorLine =
(githubData.triggerDisplayName ?? context.triggerUsername !== "Unknown") ((githubData.triggerDisplayName ?? context.triggerUsername) !== "Unknown")
? `Co-authored-by: ${githubData.triggerDisplayName ?? context.triggerUsername} <${context.triggerUsername}@users.noreply.github.com>` ? `Co-authored-by: ${githubData.triggerDisplayName ?? context.triggerUsername} <${context.triggerUsername}@users.noreply.github.com>`
: ""; : "";