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
22 changes: 12 additions & 10 deletions packages/cli/src/commands/event/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,19 @@ function issueForms(tokens: readonly string[]): IssueInput | null {
prefix === undefined || prefix.includes("/") ? prefix : `${prefix}/`;

if (second === undefined) {
const issue = issueFromEventId(id, target);
if (issue || !(prefix && looksLikeIssueShortId(prefix))) {
return issue;
}
// `<issue-short-id>/<event-id>`: the event of an issue. Short IDs are
// uppercase, and project slugs never are.
return {
eventId: ID_KINDS.event.validate(id),
targetArg: undefined,
issueShortId: prefix,
};
// uppercase, and project slugs never are. `<org>/<issue-short-id>` and
// `<org>/<numeric-issue-id>` take precedence, but not over an event ID.
const afterShortId =
prefix && looksLikeIssueShortId(prefix) && !looksLikeIssueShortId(id);
if (afterShortId && (ID_KINDS.event.isId(id) || !isAllDigits(id))) {
return {
eventId: ID_KINDS.event.validate(id),
targetArg: undefined,
issueShortId: prefix,
};
}
return issueFromEventId(id, target);
}
// `[<target>/]<issue-short-id> <event-id>`: the event of an issue. A
// second argument with a slash is a target: the arguments are reversed.
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/test/commands/event/view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ describe("parseEventViewInput", () => {
expect(result.targetArg).toBe("my-org/frontend");
});

test("reads an all-digit event ID after <short-id>/ as the issue's event", () => {
const eventId = "12345678901234567890123456789012";
const result = parseEventViewInput([`CAM-82X/${eventId}`]);
expect(result.eventId).toBe(eventId);
expect(result.issueShortId).toBe("CAM-82X");
expect(result.issueId).toBeUndefined();
});

test("rejects an incomplete event ID after <short-id>/", () => {
// Not project `CAM-82X` with a partial event ID to recover
expect(() => parseEventViewInput(["CAM-82X/95fd7f5a"])).toThrow(
Expand Down
Loading