main ece7682

path.go RawHistoryFolder

1package snapshot
2
3import (
4	"encoding/hex"
5	"fmt"
6	"path/filepath"
7	"strconv"
8	"strings"
9
10	"github.com/bnema/vev/internal/domain"
11	"github.com/bnema/vev/internal/ports"
12)
13
14const maxSnapshotFileSize = 16 + (256 << 20)
15
16func incarnationKey(id domain.IncarnationID) (string, error) {
17	if id == (domain.IncarnationID{}) {
18		return "", fmt.Errorf("snapshot: zero incarnation ID")
19	}
20	return id.String(), nil
21}
22
23func (r *Repository) sessionPath(id domain.IncarnationID) string {
24	return filepath.Join(r.dir, repositorySessionsDir, id.String())
25}
26func (r *Repository) objectPath(id domain.IncarnationID, digest ports.SnapshotDigest) string {
27	hexDigest := hex.EncodeToString(digest[:])
28	return filepath.Join(r.sessionPath(id), repositoryObjectsDir, hexDigest[:2], hexDigest)
29}
30func (r *Repository) manifestPath(id domain.IncarnationID, generation uint64) string {
31	return filepath.Join(r.sessionPath(id), repositoryGenerations, generationFilename(generation))
32}
33func (r *Repository) headPath(id domain.IncarnationID) string {
34	return filepath.Join(r.sessionPath(id), repositoryHead)
35}
36
37func generationFilename(generation uint64) string {
38	return fmt.Sprintf("%0*d.manifest", generationWidth, generation)
39}
40func parseGenerationFilename(name string) (uint64, bool) {
41	if !strings.HasSuffix(name, ".manifest") || len(name) != generationWidth+len(".manifest") {
42		return 0, false
43	}
44	n := strings.TrimSuffix(name, ".manifest")
45	generation, err := strconv.ParseUint(n, 10, 64)
46	return generation, err == nil && generationFilename(generation) == name && generation != 0
47}
48
49func parseObjectDigest(name string) (ports.SnapshotDigest, bool) {
50	var digest ports.SnapshotDigest
51	if len(name) != hex.EncodedLen(len(digest)) || strings.ToLower(name) != name {
52		return digest, false
53	}
54	_, err := hex.Decode(digest[:], []byte(name))
55	return digest, err == nil
56}

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