From 6afc12e5cdc954618c2fb9216738b4792e5b2546 Mon Sep 17 00:00:00 2001 From: anserwaseem Date: Mon, 22 Jun 2026 15:39:09 +0500 Subject: [PATCH] remove hash from release use --- src/commands/release.ts | 7 ++++--- tests/commands/release.test.ts | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/commands/release.ts b/src/commands/release.ts index c198cca..9c8c102 100644 --- a/src/commands/release.ts +++ b/src/commands/release.ts @@ -58,10 +58,11 @@ export interface ReleaseUseOptions { hash?: string; } -function formatReleaseLine(index: number, v: VersionDoc): string { +function formatReleaseLine(index: number, v: VersionDoc, showHash = true): string { const date = v.createdAt ? new Date(v.createdAt).toLocaleString() : 'Unknown date'; const msg = v.message?.trim() ? v.message : '(no message)'; - return `${index + 1}. ${date} — ${msg} [hash: ${v.id}]`; + const hashSuffix = showHash ? ` [hash: ${v.id}]` : ''; + return `${index + 1}. ${date} — ${msg}${hashSuffix}`; } function releaseUseHint(appKey: string, defaultAppKey: string): string { @@ -352,7 +353,7 @@ export async function releaseUseCommand(options: ReleaseUseOptions = {}): Promis let nextStartAfter: string | undefined = initialNext; for (;;) { const choices: { title: string; value: number | string }[] = allVersions.map((v, i) => ({ - title: formatReleaseLine(i, v), + title: formatReleaseLine(i, v, false), value: i, })); if (nextStartAfter !== undefined) { diff --git a/tests/commands/release.test.ts b/tests/commands/release.test.ts index 172bbd9..d738f93 100644 --- a/tests/commands/release.test.ts +++ b/tests/commands/release.test.ts @@ -365,6 +365,20 @@ describe('release commands', () => { ); }); + it('release use interactive picker omits hash from release labels', async () => { + Object.defineProperty(process.stdout, 'isTTY', { value: true, configurable: true }); + Object.defineProperty(process.stdin, 'isTTY', { value: true, configurable: true }); + promptsMock.mockResolvedValueOnce({ selected: 0 }); + + await releaseUseCommand({}); + + const promptArgs = promptsMock.mock.calls[0]?.[0] as { + choices: { title: string; value: number | string }[]; + }; + expect(promptArgs.choices[0]?.title).toContain('First release'); + expect(promptArgs.choices[0]?.title).not.toContain('[hash:'); + }); + it('release use --hash uses non-interactive path', async () => { // Make non-interactive by clearing TTY flags; hash should still work. Object.defineProperty(process.stdout, 'isTTY', { value: false, configurable: true });