detached 9712982

fix(lint): use ctx for debug logging in SelfUpdateBlockedReason

commit
97129829edac011f9ecc086040c90df322544736
author
bnema · · 2025-12-30 21:44 UTC
parent
d23d7eb
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +7 -1
M internal/infrastructure/updater/applier.go +6 -0
@@ -99,23 +99,29 @@ func (a *Applier) CanSelfUpdate(ctx context.Context) bool {
9999
100100 // SelfUpdateBlockedReason returns why self-update is blocked, or empty if allowed.
101101 func (a *Applier) SelfUpdateBlockedReason(ctx context.Context) port.SelfUpdateBlockedReason {
102+ log := logging.FromContext(ctx)
103+
102104 // Flatpak sandboxed apps should not self-update; Flatpak handles updates.
103105 if env.IsFlatpak() {
106+ log.Debug().Msg("self-update blocked: running in Flatpak sandbox")
104107 return port.SelfUpdateBlockedFlatpak
105108 }
106109
107110 // Pacman/AUR packages should not self-update; use pacman or AUR helper.
108111 if env.IsPacman() {
112+ log.Debug().Msg("self-update blocked: installed via pacman/AUR")
109113 return port.SelfUpdateBlockedPacman
110114 }
111115
112116 binaryPath, err := a.GetBinaryPath()
113117 if err != nil {
118+ log.Debug().Err(err).Msg("self-update blocked: failed to get binary path")
114119 return port.SelfUpdateBlockedNotWritable
115120 }
116121
117122 // Check if we have write permission on the binary file.
118123 if err := unix.Access(binaryPath, unix.W_OK); err != nil {
124+ log.Debug().Str("path", binaryPath).Err(err).Msg("self-update blocked: binary not writable")
119125 return port.SelfUpdateBlockedNotWritable
120126 }
121127
@@ -99,23 +99,29 @@ func (a *Applier) CanSelfUpdate(ctx context.Context) bool {
99 99
100 // SelfUpdateBlockedReason returns why self-update is blocked, or empty if allowed.100 // SelfUpdateBlockedReason returns why self-update is blocked, or empty if allowed.
101 func (a *Applier) SelfUpdateBlockedReason(ctx context.Context) port.SelfUpdateBlockedReason {101 func (a *Applier) SelfUpdateBlockedReason(ctx context.Context) port.SelfUpdateBlockedReason {
102+ log := logging.FromContext(ctx)
103+
102 // Flatpak sandboxed apps should not self-update; Flatpak handles updates.104 // Flatpak sandboxed apps should not self-update; Flatpak handles updates.
103 if env.IsFlatpak() {105 if env.IsFlatpak() {
106+ log.Debug().Msg("self-update blocked: running in Flatpak sandbox")
104 return port.SelfUpdateBlockedFlatpak107 return port.SelfUpdateBlockedFlatpak
105 }108 }
106 109
107 // Pacman/AUR packages should not self-update; use pacman or AUR helper.110 // Pacman/AUR packages should not self-update; use pacman or AUR helper.
108 if env.IsPacman() {111 if env.IsPacman() {
112+ log.Debug().Msg("self-update blocked: installed via pacman/AUR")
109 return port.SelfUpdateBlockedPacman113 return port.SelfUpdateBlockedPacman
110 }114 }
111 115
112 binaryPath, err := a.GetBinaryPath()116 binaryPath, err := a.GetBinaryPath()
113 if err != nil {117 if err != nil {
118+ log.Debug().Err(err).Msg("self-update blocked: failed to get binary path")
114 return port.SelfUpdateBlockedNotWritable119 return port.SelfUpdateBlockedNotWritable
115 }120 }
116 121
117 // Check if we have write permission on the binary file.122 // Check if we have write permission on the binary file.
118 if err := unix.Access(binaryPath, unix.W_OK); err != nil {123 if err := unix.Access(binaryPath, unix.W_OK); err != nil {
124+ log.Debug().Str("path", binaryPath).Err(err).Msg("self-update blocked: binary not writable")
119 return port.SelfUpdateBlockedNotWritable125 return port.SelfUpdateBlockedNotWritable
120 }126 }
121 127
M internal/infrastructure/updater/applier_test.go +1 -1
@@ -170,6 +170,6 @@ func TestSelfUpdateBlockedReason_Constants(t *testing.T) {
170170 }
171171
172172 // Verify SelfUpdateAllowed is empty string
173- assert.Equal(t, port.SelfUpdateBlockedReason(""), port.SelfUpdateAllowed,
173+ assert.Equal(t, port.SelfUpdateAllowed, port.SelfUpdateBlockedReason(""),
174174 "SelfUpdateAllowed should be empty string")
175175 }
@@ -170,6 +170,6 @@ func TestSelfUpdateBlockedReason_Constants(t *testing.T) {
170 }170 }
171 171
172 // Verify SelfUpdateAllowed is empty string172 // Verify SelfUpdateAllowed is empty string
173- assert.Equal(t, port.SelfUpdateBlockedReason(""), port.SelfUpdateAllowed,173+ assert.Equal(t, port.SelfUpdateAllowed, port.SelfUpdateBlockedReason(""),
174 "SelfUpdateAllowed should be empty string")174 "SelfUpdateAllowed should be empty string")
175 }175 }

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