detached 3483340

export_test.go RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package kvstore
4
5import (
6	"context"
7
8	kv "bnema.dev/ermite-kv"
9
10	"bnema.dev/ermite/internal/domain"
11)
12
13// SetAfterSettingsSnapshot installs the hook that runs between the snapshot of
14// DeleteEnvironment and its batch, and returns the function that removes it.
15func SetAfterSettingsSnapshot(f func()) (restore func()) {
16	afterSettingsSnapshot = f
17	return func() { afterSettingsSnapshot = nil }
18}
19
20// DecodeConcurrencyRecord, EncodeConcurrencyRecord and EncodeConcurrencyMark
21// expose the stored layout of a concurrency group to the tests.
22var (
23	DecodeConcurrencyRecord = decodeConcurrencyRecord
24	EncodeConcurrencyRecord = encodeConcurrencyRecord
25	EncodeConcurrencyMark   = encodeConcurrencyMark
26)
27
28// RawVersionForTest is the kv version of a runner record: it moves on every
29// write.
30func (c *CI) RawVersionForTest(ctx context.Context, id string) (uint64, bool) {
31	item, ok := c.db.Get(ctx, runnerKey(id))
32	return item.Version, ok
33}
34
35// CountKeysForTest counts the keys of the database under prefix.
36func (s *Store) CountKeysForTest(ctx context.Context, prefix string) int {
37	n := 0
38	for range s.db.Snapshot(ctx).Prefix(ctx, []byte(prefix)) {
39		n++
40	}
41	return n
42}
43
44// DropIssueRecordForTest deletes the issue record and leaves its open index
45// entry: the state of an index that is stale.
46func (i *Issues) DropIssueRecordForTest(ctx context.Context, repo domain.RepoName, n int64) error {
47	var b kv.Batch
48	b.Delete(issueKey(repo, n))
49	_, err := i.db.Apply(ctx, &b)
50	return err
51}
52
53// DropMRRecordForTest is DropIssueRecordForTest for a merge request.
54func (m *MergeRequests) DropMRRecordForTest(ctx context.Context, repo domain.RepoName, n int64) error {
55	var b kv.Batch
56	b.Delete(mrKey(repo, n))
57	_, err := m.db.Apply(ctx, &b)
58	return err
59}
60
61// PutRawIssueForTest stores value as the issue record, bypassing the codec.
62func (i *Issues) PutRawIssueForTest(ctx context.Context, repo domain.RepoName, n int64, value []byte) error {
63	var b kv.Batch
64	b.Put(issueKey(repo, n), value)
65	_, err := i.db.Apply(ctx, &b)
66	return err
67}

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 4

Tags 45

↑↓ moveenter openesc close