Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/commands/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions tests/commands/release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Loading