Skip to content

Commit 3f97349

Browse files
authored
remove hash from release use (#12)
1 parent 46a6fe1 commit 3f97349

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/commands/release.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ export interface ReleaseUseOptions {
5858
hash?: string;
5959
}
6060

61-
function formatReleaseLine(index: number, v: VersionDoc): string {
61+
function formatReleaseLine(index: number, v: VersionDoc, showHash = true): string {
6262
const date = v.createdAt ? new Date(v.createdAt).toLocaleString() : 'Unknown date';
6363
const msg = v.message?.trim() ? v.message : '(no message)';
64-
return `${index + 1}. ${date}${msg} [hash: ${v.id}]`;
64+
const hashSuffix = showHash ? ` [hash: ${v.id}]` : '';
65+
return `${index + 1}. ${date}${msg}${hashSuffix}`;
6566
}
6667

6768
function releaseUseHint(appKey: string, defaultAppKey: string): string {
@@ -352,7 +353,7 @@ export async function releaseUseCommand(options: ReleaseUseOptions = {}): Promis
352353
let nextStartAfter: string | undefined = initialNext;
353354
for (;;) {
354355
const choices: { title: string; value: number | string }[] = allVersions.map((v, i) => ({
355-
title: formatReleaseLine(i, v),
356+
title: formatReleaseLine(i, v, false),
356357
value: i,
357358
}));
358359
if (nextStartAfter !== undefined) {

tests/commands/release.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,20 @@ describe('release commands', () => {
365365
);
366366
});
367367

368+
it('release use interactive picker omits hash from release labels', async () => {
369+
Object.defineProperty(process.stdout, 'isTTY', { value: true, configurable: true });
370+
Object.defineProperty(process.stdin, 'isTTY', { value: true, configurable: true });
371+
promptsMock.mockResolvedValueOnce({ selected: 0 });
372+
373+
await releaseUseCommand({});
374+
375+
const promptArgs = promptsMock.mock.calls[0]?.[0] as {
376+
choices: { title: string; value: number | string }[];
377+
};
378+
expect(promptArgs.choices[0]?.title).toContain('First release');
379+
expect(promptArgs.choices[0]?.title).not.toContain('[hash:');
380+
});
381+
368382
it('release use --hash uses non-interactive path', async () => {
369383
// Make non-interactive by clearing TTY flags; hash should still work.
370384
Object.defineProperty(process.stdout, 'isTTY', { value: false, configurable: true });

0 commit comments

Comments
 (0)