process_inspector_test.go RawHistoryFolder

1package daemon
2
3import (
4	"testing"
5
6	"github.com/stretchr/testify/require"
7)
8
9func TestProcessInspectorOptionsComposition(t *testing.T) {
10	cwd := func(int) (string, error) { return "/override", nil }
11	base := &processInspectorFake{
12		cwd:  func(int) (string, error) { return "/base", nil },
13		comm: func(int) (string, error) { return "vim", nil },
14	}
15
16	tests := []struct {
17		name        string
18		opts        []Option
19		wantDetails bool
20		wantCwd     string
21		wantComm    string
22		wantCommErr error
23	}{
24		{name: "none", wantDetails: false},
25		{
26			name:        "cwd reader only",
27			opts:        []Option{WithCwdReader(cwd)},
28			wantDetails: false,
29			wantCwd:     "/override",
30			wantCommErr: errProcessInspectionUnavailable,
31		},
32		{
33			name:        "inspector only",
34			opts:        []Option{WithProcessInspector(base)},
35			wantDetails: true,
36			wantCwd:     "/base",
37			wantComm:    "vim",
38		},
39		{
40			name:        "inspector then cwd reader keeps base details",
41			opts:        []Option{WithProcessInspector(base), WithCwdReader(cwd)},
42			wantDetails: true,
43			wantCwd:     "/override",
44			wantComm:    "vim",
45		},
46		{
47			name:        "cwd reader then inspector replaces override",
48			opts:        []Option{WithCwdReader(cwd), WithProcessInspector(base)},
49			wantDetails: true,
50			wantCwd:     "/base",
51			wantComm:    "vim",
52		},
53		{
54			name:        "repeated cwd readers do not stack",
55			opts:        []Option{WithProcessInspector(base), WithCwdReader(cwd), WithCwdReader(cwd)},
56			wantDetails: true,
57			wantCwd:     "/override",
58			wantComm:    "vim",
59		},
60	}
61	for _, tt := range tests {
62		t.Run(tt.name, func(t *testing.T) {
63			d := &Daemon{}
64			for _, opt := range tt.opts {
65				opt(d)
66			}
67			require.Equal(t, tt.wantDetails, d.hasProcessDetails())
68			if d.proc == nil {
69				return
70			}
71			got, err := d.proc.Cwd(1)
72			require.NoError(t, err)
73			require.Equal(t, tt.wantCwd, got)
74			comm, err := d.proc.Comm(1)
75			require.ErrorIs(t, err, tt.wantCommErr)
76			require.Equal(t, tt.wantComm, comm)
77			if o, ok := d.proc.(cwdOverrideInspector); ok {
78				_, nested := o.base.(cwdOverrideInspector)
79				require.False(t, nested)
80			}
81		})
82	}
83}

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 12

Tags 11

↑↓ moveenter openesc close