Skip to content

Commit c8d2751

Browse files
fix(client-runtime): skip archived: and read me and @me as one author
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 30119a7 commit c8d2751

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎packages/client-runtime/src/pullRequestQuery.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("reading qualifiers out of a typed query", () => {
5757
it("ignores GitHub's own search qualifiers instead of reading them as labels", () => {
5858
expect(
5959
parsePullRequestQuery(
60-
"is:pr state:open repo:org/repo org:org user:alice sort:updated-desc -repo:org/fork -state:closed fix",
60+
"is:pr state:open archived:false repo:org/repo org:org user:alice sort:updated-desc -repo:org/fork -state:closed fix",
6161
),
6262
).toEqual({ text: "fix", filters: {} });
6363
});
@@ -70,6 +70,7 @@ describe("reading qualifiers out of a typed query", () => {
7070
it("sets no author when the query names more than one", () => {
7171
expect(parsePullRequestQuery("author:alice author:bob").filters).toEqual({});
7272
expect(parsePullRequestQuery("author:alice author:alice").filters).toEqual({ author: "alice" });
73+
expect(parsePullRequestQuery("author:me author:@me").filters).toEqual({ author: "me" });
7374
});
7475

7576
it("cuts a typed query back to what the contract carries", () => {

‎packages/client-runtime/src/pullRequestQuery.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ function splitQualifierList(raw: string): string[] {
2929
.filter((part) => part.length > 0);
3030
}
3131

32+
/** `me` and `@me` both name the viewer; logins are case-insensitive. */
33+
function authorKey(login: string): string {
34+
return login.toLowerCase().replace(/^@me$/, "me");
35+
}
36+
3237
function boundedNames(names: ReadonlyArray<string>): string[] {
3338
return names
3439
.slice(0, MAX_QUALIFIER_VALUES)
@@ -64,7 +69,7 @@ export function parsePullRequestQuery(raw: string): {
6469
if (negated) break;
6570
const login = value.slice(0, MAX_QUALIFIER_LENGTH).trim();
6671
if (author === undefined) author = login;
67-
else if (author?.toLowerCase() !== login.toLowerCase()) author = null;
72+
else if (author === null || authorKey(author) !== authorKey(login)) author = null;
6873
continue;
6974
}
7075
case "draft":
@@ -86,6 +91,7 @@ export function parsePullRequestQuery(raw: string): {
8691
}
8792
// GitHub's own search qualifiers, not labels: the list sets scope and order itself.
8893
case "is":
94+
case "archived":
8995
case "state":
9096
case "repo":
9197
case "org":

0 commit comments

Comments
 (0)