GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): keep numeric merge subjects from matching the wrong PR w… · patroza/t3code@cbf5c78

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/sourceControl
    • sourceControlDefinitions.test.ts
    • sourceControlDefinitions.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/sourceControl/sourceControlDefinitions.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/sourceControl/sourceControlDefinitions.test.ts
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,23 @@ it.each([
6161
["gh pr merge 19 --squash", [19]],
6262
['gh pr merge "19" --squash', [19]],
6363
['/bin/zsh -lc "gh pr merge 19"', [19]],
64+
['/bin/zsh -lc "gh pr merge 19" > "merge.log"', [19]],
65+
[`/bin/zsh -lc 'gh pr merge 19' > 'merge.log'`, [19]],
6466
['gh pr merge 19 --squash --subject "Release 20"', [19]],
6567
[`/bin/zsh -lc "gh pr merge 19 --subject 'Release 20'"`, [19]],
6668
["gh pr merge 19 --body 'see https://github.com/o/r/pull/20'", [19]],
6769
["gh pr merge 19 --body https://github.com/o/r/pull/20", [19]],
6870
["gh pr merge 19 # then 20", [19]],
6971
["gh pr merge --squash --match-head-commit 3b2f958 #19", [19]],
72+
["gh pr merge --squash --subject=2026 42", [42]],
73+
['gh pr merge --squash --subject="2026" 42', [42]],
74+
["gh pr merge --body=https://github.com/o/r/pull/20 19", [19]],
7075
["gh pr close https://github.com/o/r/pull/19 && gh pr merge 20", [19, 20]],
7176
["glab mr merge https://gitlab.com/o/r/-/merge_requests/7", [7]],
7277
["sleep 30; cafe pr merge 26271", [26271]],
7378
["az repos pr update --id 19 --status completed", [19]],
7479
["az repos pr update --id=19 --status=abandoned", [19]],
80+
['az repos pr update --id="19" --title "20" --status completed', [19]],
7581
["gh pr merge --squash", "any"],
7682
["gh stack merge", "any"],
7783
["gh pr merge 19 && gh pr merge --auto", "any"],
Collapse file

‎apps/server/src/sourceControl/sourceControlDefinitions.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/sourceControl/sourceControlDefinitions.ts
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ export const isChangeRequestCloseCommand = (command: string) =>
3232
);
3333

3434
// A quoted or bare shell word. An unclosed quote, as Codex's `/bin/zsh -lc "gh pr merge 19"`
35-
// leaves after the match, runs to the end.
36-
const SHELL_WORD = /"((?:\\[\s\S]|[^"\\])*)"?|'([^']*)'?|((?:\\[\s\S]|[^\s"'\\])+)/gu;
37-
// A whole word that names one, so a number inside `--subject "Release 20"` does not.
38-
const NAMED_CHANGE_REQUEST = /^(?:--?[\w-]+=)?#?(\d+)$|^\S*\/(?:pulls?|merge_requests)\/(\d+)\/?$/u;
35+
// leaves after the match, runs to the end. A closed one right after `=` stays in that word and is
36+
// unquoted before matching, so `--id="19"` names 19 and `--subject="20"` names none, while the
37+
// wrapper's closing quote in `-lc "gh pr merge 19" > "log"` still ends the word `19`.
38+
const SHELL_WORD =
39+
/"((?:\\[\s\S]|[^"\\])*)"?|'([^']*)'?|((?:\\[\s\S]|[^\s"'\\])+(?:(?<==)(?:"(?:\\[\s\S]|[^"\\])*"|'[^']*'))?)/gu;
40+
// A whole word that names one, so a number inside `--subject "Release 20"` does not. Of the
41+
// hosts' close commands only Azure's selects one with a flag, so `--subject=2026` and
42+
// `--body=<pull request URL>` are option text.
43+
const NAMED_CHANGE_REQUEST = /^(?:--id=)?#?(\d+)$|^(?!-)\S*\/(?:pulls?|merge_requests)\/(\d+)\/?$/u;
3944

4045
/**
4146
* The change request numbers a merge or close command names, or "any" when one names none, as a
@@ -53,7 +58,8 @@ export function changeRequestsClosedBy(command: string): ReadonlySet<number> | "
5358
for (const [, double, single, bare] of args.matchAll(SHELL_WORD)) {
5459
// A comment ends the command.
5560
if (bare !== undefined && /^#(?!\d+$)/u.test(bare)) break;
56-
const [, number, url] = NAMED_CHANGE_REQUEST.exec(double ?? single ?? bare ?? "") ?? [];
61+
const word = double ?? single ?? bare?.replace(/\\([\s\S])|["']/gu, "$1") ?? "";
62+
const [, number, url] = NAMED_CHANGE_REQUEST.exec(word) ?? [];
5763
target = number ?? url;
5864
if (target !== undefined) break;
5965
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.