Commit d6663a0512

d6663a051268e7f1016bf0adcfb81b5cd0934396

parent: 583b480f3a

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-02 03:16 UTC

cli: send the inferred repository as here= in --term

Ref #317

Layout: unified · split

cmd/gitbay/ssh.go +7 −3
@@ -119,8 +119,9 @@ var noColor bool
119119// output stays the rows stock ssh prints, and when GITBAY_TERM is "off",
120120// for an instance older than --term. GITBAY_TERM=basic sends the width
121121// and colour only, for an instance older than truecolor and links, which
122// turns any other option into plain output.
123func termValue(isTerminal bool, cols int, env func(string) string) string {
122// turns any other option into plain output. here is the repository
123// inferred from the clone, for suggested commands to leave out.
124func termValue(isTerminal bool, cols int, here string, env func(string) string) string {
124125 if !isTerminal || cols < 40 || env("GITBAY_TERM") == "off" {
125126 return ""
126127 }
@@ -138,6 +139,9 @@ func termValue(isTerminal bool, cols int, env func(string) string) string {
138139 if linksWanted(env) {
139140 v += ",links"
140141 }
142 if here != "" {
143 v += ",here=" + here
144 }
141145 return v
142146}
143147
@@ -235,7 +239,7 @@ func runSSHPaged(t target, serverArgv []string, stdin io.Reader, page bool) int
235239 if isTTY {
236240 cols, _, _ = term.GetSize(fd)
237241 }
238 if v := termValue(isTTY, cols, os.Getenv); v != "" && !slices.Contains(serverArgv, "--json") {
242 if v := termValue(isTTY, cols, t.repo, os.Getenv); v != "" && !slices.Contains(serverArgv, "--json") {
239243 serverArgv = append([]string{"--term=" + v}, serverArgv...)
240244 }
241245
cmd/gitbay/term_test.go +14 −1
@@ -37,13 +37,26 @@ func TestTermValue(t *testing.T) {
3737 }
3838 for _, c := range cases {
3939 noColor = c.noColor
40 if got := termValue(c.tty, c.cols, env(c.env)); got != c.want {
40 if got := termValue(c.tty, c.cols, "", env(c.env)); got != c.want {
4141 t.Errorf("%+v: got %q", c, got)
4242 }
4343 }
4444 noColor = false
4545}
4646
47func TestTermValueHere(t *testing.T) {
48 env := func(string) string { return "" }
49 if got, want := termValue(true, 100, "krz/gitbay", env), "100,color,here=krz/gitbay"; got != want {
50 t.Errorf("got %q, want %q", got, want)
51 }
52 if got := termValue(true, 100, "", env); strings.Contains(got, "here=") {
53 t.Errorf("here= without a repository: %q", got)
54 }
55 if got := termValue(false, 100, "krz/gitbay", env); got != "" {
56 t.Errorf("piped: %q", got)
57 }
58}
59
4760func TestStripNoColor(t *testing.T) {
4861 args, ok := stripNoColor([]string{"gitbay", "issue", "list", "--no-color", "--state", "all"})
4962 if !ok || len(args) != 5 || args[3] != "--state" {