v0.9.0 e5e4ded

proto_convert_preview.go RawHistoryFolder

1package sessionwire
2
3// RemotePreviewWatch/RemotePreview converters delegate their field-by-field
4// logic to internal/adapters/protoconv, the canonical implementation shared
5// with brokerwire. sessionwire's policy is to collapse every failure -
6// whether a narrowing range failure or a semantic validation failure - into
7// one fixed sentinel per direction (protocol.ErrInvalidRemotePreviewWatch
8// or protocol.ErrInvalidRemotePreview), except that remotePreviewToWire
9// still distinguishes protoconv's own ErrOutOfRange (encoded as
10// errProtoConvertRange) from a protocol validation failure (passed through
11// unchanged), matching this file's pre-extraction behavior exactly.
12
13import (
14	"errors"
15	"time"
16
17	"github.com/bnema/vev/internal/adapters/protoconv"
18	"github.com/bnema/vev/internal/protocol"
19	"github.com/bnema/vev/internal/protocol/wire"
20)
21
22// remotePreviewWatchToWire carries the watch interval as whole milliseconds.
23func remotePreviewWatchToWire(message protocol.RemotePreviewWatch) (*wire.RemotePreviewWatch, error) {
24	if protocol.ValidateRemotePreviewWatch(message) != nil {
25		return nil, protocol.ErrInvalidRemotePreviewWatch
26	}
27	request, err := protoconv.RemotePreviewRequestToWire(message.Request)
28	if err != nil {
29		return nil, protocol.ErrInvalidRemotePreviewWatch
30	}
31	return &wire.RemotePreviewWatch{Request: request, MinIntervalMs: uint32(message.MinInterval / time.Millisecond)}, nil
32}
33
34func remotePreviewWatchFromWire(message *wire.RemotePreviewWatch) (protocol.RemotePreviewWatch, error) {
35	if message == nil || message.GetRequest() == nil {
36		return protocol.RemotePreviewWatch{}, protocol.ErrInvalidRemotePreviewWatch
37	}
38	request, err := protoconv.RemotePreviewRequestFromWire(message.GetRequest())
39	if err != nil {
40		return protocol.RemotePreviewWatch{}, protocol.ErrInvalidRemotePreviewWatch
41	}
42	interval := message.GetMinIntervalMs()
43	if interval > uint32(protocol.RemotePreviewWatchMaxInterval/time.Millisecond) {
44		return protocol.RemotePreviewWatch{}, protocol.ErrInvalidRemotePreviewWatch
45	}
46	watch := protocol.RemotePreviewWatch{Request: request, MinInterval: time.Duration(interval) * time.Millisecond}
47	if protocol.ValidateRemotePreviewWatch(watch) != nil {
48		return protocol.RemotePreviewWatch{}, protocol.ErrInvalidRemotePreviewWatch
49	}
50	return watch, nil
51}
52
53func remotePreviewToWire(message protocol.RemotePreview) (*wire.RemotePreview, error) {
54	out, err := protoconv.RemotePreviewToWire(message)
55	if err != nil {
56		if errors.Is(err, protoconv.ErrOutOfRange) {
57			return nil, errProtoConvertRange
58		}
59		return nil, err
60	}
61	return out, nil
62}
63
64func remotePreviewFromWire(message *wire.RemotePreview) (protocol.RemotePreview, error) {
65	if message == nil {
66		return protocol.RemotePreview{}, protocol.ErrInvalidRemotePreview
67	}
68	preview, err := protoconv.RemotePreviewFromWire(message)
69	if err != nil {
70		return protocol.RemotePreview{}, protocol.ErrInvalidRemotePreview
71	}
72	return preview, nil
73}

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