detached fda3c2b

mergetree_bound_test.go RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package domain_test
4
5import (
6	"strconv"
7	"testing"
8
9	"github.com/stretchr/testify/assert"
10	"github.com/stretchr/testify/require"
11
12	"bnema.dev/ermite/internal/domain"
13)
14
15func TestMergeTreeResultBounded(t *testing.T) {
16	var paths []string
17	for i := 0; i < domain.MaxConflictPaths+2; i++ {
18		paths = append(paths, strconv.Itoa(i))
19	}
20	got := domain.MergeTreeResult{ConflictPaths: paths}.Bounded()
21	assert.Len(t, got.ConflictPaths, domain.MaxConflictPaths)
22	assert.True(t, got.Truncated)
23
24	got = domain.MergeTreeResult{ConflictPaths: paths[:domain.MaxConflictPaths]}.Bounded()
25	assert.Len(t, got.ConflictPaths, domain.MaxConflictPaths)
26	assert.False(t, got.Truncated)
27}
28
29func TestBoundBehind(t *testing.T) {
30	n, capped := domain.BoundBehind(domain.MaxBehindCount)
31	assert.Equal(t, domain.MaxBehindCount, n)
32	assert.False(t, capped)
33	n, capped = domain.BoundBehind(domain.BehindLimit)
34	assert.Equal(t, domain.MaxBehindCount, n)
35	assert.True(t, capped)
36}
37
38func TestMergeTreeResultBoundedCopiesThePaths(t *testing.T) {
39	var paths []string
40	for i := 0; i < domain.MaxConflictPaths+2; i++ {
41		paths = append(paths, strconv.Itoa(i))
42	}
43	got := domain.MergeTreeResult{ConflictPaths: paths}.Bounded()
44	require.Len(t, got.ConflictPaths, domain.MaxConflictPaths)
45	assert.Equal(t, len(got.ConflictPaths), cap(got.ConflictPaths))
46	assert.NotSame(t, &paths[0], &got.ConflictPaths[0], "a new array, not the git output's")
47	assert.Equal(t, paths[:domain.MaxConflictPaths], got.ConflictPaths)
48
49	got = domain.MergeTreeResult{ConflictPaths: paths[:3:10]}.Bounded()
50	assert.Equal(t, 3, cap(got.ConflictPaths))
51	assert.False(t, got.Truncated)
52	assert.Nil(t, domain.MergeTreeResult{}.Bounded().ConflictPaths)
53}

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 2

Tags 45

↑↓ moveenter openesc close