updater.go RawHistoryFolder

1// Package port defines interfaces for external dependencies.
2package port
3
4import (
5	"context"
6	"errors"
7
8	"github.com/bnema/dumber/internal/domain/entity"
9)
10
11// ErrUpdateCheckTransient indicates a temporary update-check failure that should not be treated as actionable.
12var ErrUpdateCheckTransient = errors.New("transient update check failure")
13
14// UpdateChecker checks for available updates from a remote source.
15type UpdateChecker interface {
16	// CheckForUpdate compares the current version with the latest available release.
17	// Returns update info including whether a newer version is available.
18	CheckForUpdate(ctx context.Context, currentVersion string) (*entity.UpdateInfo, error)
19}
20
21// UpdateDownloader downloads and extracts update archives.
22type UpdateDownloader interface {
23	// Download fetches the update archive to the specified destination directory.
24	// Returns the path to the downloaded archive file.
25	Download(ctx context.Context, downloadURL string, destDir string) (archivePath string, err error)
26
27	// Extract extracts the binary from the downloaded archive.
28	// Returns the path to the extracted binary.
29	Extract(ctx context.Context, archivePath string, destDir string) (binaryPath string, err error)
30}
31
32// SelfUpdateBlockedReason indicates why self-update is not available.
33type SelfUpdateBlockedReason string
34
35const (
36	// SelfUpdateAllowed means self-update is possible.
37	SelfUpdateAllowed SelfUpdateBlockedReason = ""
38	// SelfUpdateBlockedFlatpak means updates are managed by Flatpak.
39	SelfUpdateBlockedFlatpak SelfUpdateBlockedReason = "flatpak"
40	// SelfUpdateBlockedPacman means updates are managed by pacman/AUR.
41	SelfUpdateBlockedPacman SelfUpdateBlockedReason = "pacman"
42	// SelfUpdateBlockedNotWritable means the binary is not writable.
43	SelfUpdateBlockedNotWritable SelfUpdateBlockedReason = "not_writable"
44)
45
46// UpdateApplier stages and applies updates.
47type UpdateApplier interface {
48	// CanSelfUpdate checks if the current binary is writable by the current user.
49	// Returns true if auto-update is possible, false if user lacks write permission.
50	CanSelfUpdate(ctx context.Context) bool
51
52	// SelfUpdateBlockedReason returns why self-update is blocked, or empty if allowed.
53	SelfUpdateBlockedReason(ctx context.Context) SelfUpdateBlockedReason
54
55	// GetBinaryPath returns the path to the currently running binary.
56	GetBinaryPath() (string, error)
57
58	// StageUpdate prepares the new binary to be applied on exit.
59	// The staged update will be applied when ApplyOnExit is called.
60	StageUpdate(ctx context.Context, newBinaryPath string) error
61
62	// HasStagedUpdate checks if there is an update staged and ready to apply.
63	HasStagedUpdate(ctx context.Context) bool
64
65	// ApplyOnExit replaces the current binary with the staged update.
66	// This should be called during graceful shutdown.
67	// Returns the path to the backup of the old binary.
68	ApplyOnExit(ctx context.Context) (backupPath string, err error)
69
70	// ClearStagedUpdate removes any staged update without applying it.
71	ClearStagedUpdate(ctx context.Context) error
72}

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 8

Tags 42

↑↓ moveenter openesc close