v0.26.0 df1db36

ci_pullattempts_test.go RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package usecase
4
5import (
6	"strconv"
7	"strings"
8	"testing"
9
10	"github.com/stretchr/testify/assert"
11	"github.com/stretchr/testify/require"
12
13	"bnema.dev/ermite/internal/domain"
14)
15
16func TestPullAttemptsRememberConflictsByTipsAndAreBounded(t *testing.T) {
17	id := func(c string) domain.ObjectID {
18		o, err := domain.ParseObjectID(strings.Repeat(c, 40))
19		require.NoError(t, err)
20		return o
21	}
22	key := func(i int) pullKey {
23		r, err := domain.ParseRepoName("r" + strconv.Itoa(i))
24		require.NoError(t, err)
25		return pullKey{repo: r, number: 1}
26	}
27	a := newPullAttempts(2)
28	a.conflicted(key(0), id("a"), id("b"))
29	assert.True(t, a.tried(key(0), id("a"), id("b")), "the same tips were tried")
30	assert.False(t, a.tried(key(0), id("c"), id("b")), "the target moved: try again")
31	assert.False(t, a.tried(key(0), id("a"), id("c")), "the source moved: try again")
32	assert.False(t, a.tried(key(1), id("a"), id("b")), "another merge request")
33
34	a.conflicted(key(1), id("a"), id("b"))
35	a.tried(key(0), id("a"), id("b")) // 0 is the most recently used; 1 the oldest
36	a.conflicted(key(2), id("a"), id("b"))
37	assert.False(t, a.tried(key(1), id("a"), id("b")), "the least recently used is forgotten")
38	assert.True(t, a.tried(key(0), id("a"), id("b")))
39	assert.True(t, a.tried(key(2), id("a"), id("b")))
40	assert.Len(t, a.items, 2)
41	assert.Len(t, a.order, 2)
42
43	a.merged(key(0))
44	assert.False(t, a.tried(key(0), id("a"), id("b")), "a merge that went through is forgotten")
45	assert.Len(t, a.items, 1)
46	assert.Len(t, a.order, 1)
47}

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 3

Tags 44

↑↓ moveenter openesc close