Commit 32a9534
authored
feat(style): hyperlink PR numbers in submit output (#107)
* feat(style): hyperlink PR numbers in submit output (#105)
submit prints "Updating PR #N for branch (base: parent)..." with no
URL. Per the issue, the PR number should be the linked text when the
terminal supports OSC 8 hyperlinks; otherwise fall back to "text (URL)"
so the URL remains visible.
Added Hyperlink(text, url) to internal/style/style.go:
- Color/TTY enabled: emits OSC 8 escape sequence
(\x1b]8;;URL\x1b\\TEXT\x1b]8;;\x1b\\), which renders as a clickable
link in iTerm2, kitty, recent macOS Terminal, GNOME Terminal, etc.
- Color/TTY disabled (NO_COLOR, piped output, dumb terminal):
falls back to "text (url)".
- Empty URL: returns text alone, no parens.
Updated cmd/submit.go:465 to wrap "PR #N" with Hyperlink() and
ghClient.PRURL(d.prNum). The (base: parent) suffix and trailing
"... ok" / "failed" are unchanged.
Added internal/style/style_test.go covering the three branches
(enabled, disabled, empty URL).
Closes #105
* fix(style): gate OSC 8 hyperlinks on TTY and assert full sequence
Address review feedback from copilot-pull-request-reviewer[bot]:
- Hyperlink now requires both s.enabled and s.isTTY before emitting
OSC 8, so CLICOLOR_FORCE / GH_FORCE_TTY no longer leaks escape
sequences into piped output. NewWithColor(enabled) sets isTTY to
match enabled so existing test behavior is preserved.
- TestHyperlinkColorsEnabled now asserts the full OSC 8 sequence
including the closing terminator, catching malformed or truncated
output that the prior substring checks would have missed.
---------
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>1 parent 2b49c2b commit 32a9534
3 files changed
Lines changed: 58 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
| 465 | + | |
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
58 | 62 | | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
63 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
| |||
191 | 198 | | |
192 | 199 | | |
193 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments