v0.8.0 eaf4295

bigrepo_test.go RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package ermitegit_test
4
5import (
6	"context"
7	"os"
8	"os/exec"
9	"path/filepath"
10	"testing"
11
12	"github.com/stretchr/testify/require"
13
14	"bnema.dev/ermite/internal/adapters/gitcli"
15	"bnema.dev/ermite/internal/domain"
16)
17
18// EnvBenchRepo names a real repository (its .git directory) for the
19// comparison test and the benchmarks, which skip without it. It is never
20// modified: it is cloned.
21const EnvBenchRepo = "ERMITE_GIT_BENCH_REPO"
22
23// bigRepo is a bare clone of the repository of EnvBenchRepo, configured like
24// a repository ermite creates and maintained the way ermite does.
25type bigRepo struct {
26	name domain.RepoName
27	dir  string
28}
29
30// cloneBench clones the repository of EnvBenchRepo into the data directory with
31// --no-local (a real pack transfer, so that the clone is packed as a push
32// would leave it), applies the settings of gitcli.Stage and runs
33// gitcli.Maintain. It skips the test when the variable is unset.
34func cloneBench(tb testing.TB, g *gitcli.Git, data string) bigRepo {
35	tb.Helper()
36	src := os.Getenv(EnvBenchRepo)
37	if src == "" {
38		tb.Skipf("%s is not set", EnvBenchRepo)
39	}
40	name, err := domain.ParseRepoName("bench")
41	require.NoError(tb, err)
42	dir := gitcli.RepoDir(data, name)
43	run := func(args ...string) {
44		tb.Helper()
45		cmd := exec.Command("git", args...)
46		cmd.Env = []string{"PATH=" + os.Getenv("PATH"), "HOME=" + filepath.Join(data, "run", "git-home"), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null"}
47		out, err := cmd.CombinedOutput()
48		require.NoError(tb, err, "git %v: %s", args, out)
49	}
50	run("clone", "--quiet", "--bare", "--no-local", src, dir)
51	for _, kv := range [][2]string{{"repack.writeBitmaps", "true"}, {"core.commitGraph", "true"}, {"commitGraph.changedPathsVersion", "2"}} {
52		run("-C", dir, "config", "--local", kv[0], kv[1])
53	}
54	run("-C", dir, "gc", "--quiet", "--prune=now")
55	require.NoError(tb, g.Maintain(context.Background(), name))
56	return bigRepo{name: name, dir: dir}
57}

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