v2.30.1 1983e1b

config_test.go RawHistoryFolder

1package remote
2
3import (
4	"os"
5	"path/filepath"
6	"testing"
7)
8
9func TestResolveRemote_InsecureTLSFromClientConfig(t *testing.T) {
10	t.Setenv("XDG_CONFIG_HOME", t.TempDir())
11
12	cfg := []byte(`
13[client]
14mode = "remote"
15remote = "https://gordon.example.com"
16insecure_tls = true
17`)
18	path := DefaultClientConfigPath()
19	if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
20		t.Fatalf("mkdir config dir: %v", err)
21	}
22	if err := os.WriteFile(path, cfg, 0o600); err != nil {
23		t.Fatalf("write config: %v", err)
24	}
25
26	url, _, insecure, isRemote := ResolveRemote("", "", false)
27	if !isRemote {
28		t.Fatalf("expected remote mode")
29	}
30	if url != "https://gordon.example.com" {
31		t.Fatalf("unexpected url: %s", url)
32	}
33	if !insecure {
34		t.Fatalf("expected insecure TLS true from client config")
35	}
36}
37
38func TestResolveInsecureTLSForRemote_FromRemoteEntry(t *testing.T) {
39	t.Setenv("XDG_CONFIG_HOME", t.TempDir())
40
41	remotes := &ClientConfig{
42		Active: "prod",
43		Remotes: map[string]RemoteEntry{
44			"prod": {
45				URL:         "https://gordon.example.com",
46				InsecureTLS: true,
47			},
48		},
49	}
50	if err := SaveRemotes("", remotes); err != nil {
51		t.Fatalf("save remotes: %v", err)
52	}
53
54	if !ResolveInsecureTLSForRemote(false, "prod") {
55		t.Fatalf("expected insecure TLS true from remote entry")
56	}
57}
58
59func TestResolveInsecureTLSForRemote_DefaultSecure(t *testing.T) {
60	t.Setenv("XDG_CONFIG_HOME", t.TempDir())
61
62	// With no flag, no env, and no config, TLS should be secure by default
63	if ResolveInsecureTLSForRemote(false, "") {
64		t.Fatalf("expected insecure TLS false by default")
65	}
66}
67
68func TestResolveInsecureTLSForRemote_EnvAndFlagPrecedence(t *testing.T) {
69	t.Setenv("XDG_CONFIG_HOME", t.TempDir())
70	t.Setenv("GORDON_INSECURE", "true")
71
72	// env=true should enable when flag is false
73	if !ResolveInsecureTLSForRemote(false, "") {
74		t.Fatalf("expected insecure TLS true from env")
75	}
76
77	// flag=true should always enable
78	if !ResolveInsecureTLSForRemote(true, "") {
79		t.Fatalf("expected insecure TLS true from flag")
80	}
81}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close