From 1753630c73d262511c492e3c5b8cab29823e6201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Einar=20Bergstr=C3=B8m?= Date: Thu, 15 Oct 2026 10:38:56 +0200 Subject: [PATCH] chore: tidy comments that repeat the code or no longer match it (#72) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Comments that only restate a name (sgr, fg, mdLink, the repo provider's starred and current-repo notes) are gone. - Stale ones match the code again: the repo package covers plain env files too, Launch runs argv, closeVersions no longer claims to move the cursor, and Check's fallback says why rather than naming a state no release had. - The doc for versionString was attached to pseudo; the backtick in SourcesView's doc was a string-concatenation leftover; openFailed's doc was garbled. - recentReleases sits next to latest, its user. - .gitignore drops the Go template's boilerplate and patterns for files this project doesn't make. Reviewed-on: https://git.kebcloud.no/keb/lazysecrets/pulls/72 Co-authored-by: Karl-Einar Bergstrøm --- .gitignore | 36 ++++++-------------------- cmd/lazysecrets/version.go | 6 ++--- internal/config/config.go | 3 ++- internal/linkhandler/install_darwin.go | 2 +- internal/linkhandler/terminal.go | 2 +- internal/provider/repo/repo.go | 5 +--- internal/ui/app/app.go | 3 +-- internal/ui/app/sharefiles.go | 2 +- internal/ui/panes/highlight.go | 1 - internal/ui/styles/theme.go | 1 - internal/update/update.go | 8 +++--- 11 files changed, 21 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index a87d716..6d571f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,33 +1,13 @@ -# ---> Go -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work -go.work.sum - -# env file -.env - - # Build output /lazysecrets # Release builds (GoReleaser, see .goreleaser.yaml) /dist/ + +# go test -c, coverage profiles +*.test +*.out + +go.work +go.work.sum +.env diff --git a/cmd/lazysecrets/version.go b/cmd/lazysecrets/version.go index 19ebf32..316d26f 100644 --- a/cmd/lazysecrets/version.go +++ b/cmd/lazysecrets/version.go @@ -11,13 +11,13 @@ import ( // go build -ldflags "-X main.version=1.2.3" ./cmd/lazysecrets var version string -// versionString is the release version, or for other builds what Go -// recorded: the module version (go install …@v1.2.3), else the commit -// (dev-c1a4f90, -dirty with changes not committed). // pseudo matches a Go pseudo-version (v0.1.3-0.20261014174204-1c31a75d0507, // maybe +dirty): its commit. var pseudo = regexp.MustCompile(`[-.]\d{14}-([0-9a-f]{12})(\+.*)?$`) +// versionString is the release version, or for other builds what Go +// recorded: the module version (go install …@v1.2.3), else the commit +// (dev-c1a4f90, -dirty with changes not committed). func versionString() string { if version != "" { return version diff --git a/internal/config/config.go b/internal/config/config.go index 11c7da3..c1db051 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -47,7 +47,8 @@ type UI struct { // RecentIcon marks items used lately (Recent, R) with ◷, in the lists // and in lazysecrets list. Defaults to false. RecentIcon *bool `yaml:"recentIcon"` - // SourcesView is "grouped" (default) or "flat"; ` + "`" + ` toggles it. + // SourcesView is "grouped" (default) or "flat"; the backtick key + // toggles it. SourcesView string `yaml:"sourcesView"` // CollapseGroups starts the Sources pane with its groups folded; // defaults to true. diff --git a/internal/linkhandler/install_darwin.go b/internal/linkhandler/install_darwin.go index 030bd0f..c9eb062 100644 --- a/internal/linkhandler/install_darwin.go +++ b/internal/linkhandler/install_darwin.go @@ -114,7 +114,7 @@ func Check() string { } out, err := exec.Command("plutil", "-extract", exeKey, "raw", filepath.Join(app, "Contents", "Info.plist")).Output() if err != nil { - return "" // installed before the key was recorded: assume it works + return "" // can't tell: assume it works } if exe := strings.TrimSpace(string(out)); !exists(exe) { return "lazysecrets:// links run " + exe + ", which no longer exists" diff --git a/internal/linkhandler/terminal.go b/internal/linkhandler/terminal.go index 6776f37..fd90735 100644 --- a/internal/linkhandler/terminal.go +++ b/internal/linkhandler/terminal.go @@ -140,7 +140,7 @@ func appleString(s string) string { return `"` + strings.NewReplacer(`\`, `\\`, `"`, `\"`).Replace(s) + `"` } -// Launch opens a new terminal window running inner, without waiting for +// Launch opens a new terminal window running argv, without waiting for // it. func Launch(argv []string) error { cmd := exec.Command(argv[0], argv[1:]...) diff --git a/internal/provider/repo/repo.go b/internal/provider/repo/repo.go index 3f61d07..1a79067 100644 --- a/internal/provider/repo/repo.go +++ b/internal/provider/repo/repo.go @@ -1,6 +1,6 @@ // Package repo browses the encrypted secret files in git repositories: // a repo is a source, its secret files the containers (vault level), and -// their keys the secrets. SOPS files are the one type so far. +// their keys the secrets. Secret files are SOPS files and plain env files. // // Listing never decrypts: SOPS encrypts values only, so a file's keys and // metadata are read directly. A value is decrypted when it's revealed or @@ -106,8 +106,6 @@ func (p *Provider) load() { roots = append(roots, root) } } - // The repo lazysecrets started in, if any: marked, so the UI can - // put it on top, with its files under Dir first. here, inRepo := p.current() if inRepo { seen[here.root] = true @@ -137,7 +135,6 @@ func (p *Provider) load() { add(root) } } - // Repos you starred something in, wherever they are. for _, dir := range p.s.Starred { if root, err := gitRoot(dir); err == nil { add(root) diff --git a/internal/ui/app/app.go b/internal/ui/app/app.go index 29c9f50..d9e01a9 100644 --- a/internal/ui/app/app.go +++ b/internal/ui/app/app.go @@ -1319,8 +1319,7 @@ func (m *Model) countVersions(o provider.Object) tea.Cmd { }) } -// closeVersions returns the Secrets pane to the object list, with the -// cursor on the object whose versions were shown. +// closeVersions returns the Secrets pane to the object list. func (m *Model) closeVersions() { m.versionsOf = nil } diff --git a/internal/ui/app/sharefiles.go b/internal/ui/app/sharefiles.go index d693b27..4bee85b 100644 --- a/internal/ui/app/sharefiles.go +++ b/internal/ui/app/sharefiles.go @@ -304,7 +304,7 @@ func (m *Model) handleShareOpened(msg shareOpenedMsg) tea.Cmd { } // openFailed says why a share link couldn't be decrypted, in a popup -// where its offer was: its first line (wrapped), or with whole all of it +// where its offer was: its first line (wrapped), or, with whole, all of it // (Key Vault's refusals say what to check on later lines). From there, // the key's secret can be gone to: its version, which may be disabled. func (m *Model) openFailed(s share.Sealed, err error, whole bool) { diff --git a/internal/ui/panes/highlight.go b/internal/ui/panes/highlight.go index af2f05e..bcc6f15 100644 --- a/internal/ui/panes/highlight.go +++ b/internal/ui/panes/highlight.go @@ -9,7 +9,6 @@ import ( "github.com/charmbracelet/x/ansi" ) -// sgr matches SGR escape sequences. var sgr = regexp.MustCompile("\x1b\\[([0-9;:]*)m") // Highlight draws a cursor row: line, padded to width, on style's diff --git a/internal/ui/styles/theme.go b/internal/ui/styles/theme.go index 6576e32..74b2193 100644 --- a/internal/ui/styles/theme.go +++ b/internal/ui/styles/theme.go @@ -131,7 +131,6 @@ type value struct { bold, italic, underline, reverse, faint bool } -// fg styles s with the value as foreground, bg as background. func (v value) fg(s lipgloss.Style) lipgloss.Style { if v.color != nil { s = s.Foreground(v.color) diff --git a/internal/update/update.go b/internal/update/update.go index c78de13..5f45204 100644 --- a/internal/update/update.go +++ b/internal/update/update.go @@ -89,14 +89,9 @@ func (r Release) Notes(current string) string { return PlainLinks(strings.TrimSpace(notes)) } -// recentReleases is how many releases Latest reads the changelogs of. -const recentReleases = 10 - // PlainLinks shows Markdown links as their text, for a terminal. func PlainLinks(s string) string { return mdLink.ReplaceAllString(s, "$1") } -// mdLink is a Markdown link, [text](url): the notes link PRs and commits, -// and a terminal shows them as their text. var mdLink = regexp.MustCompile(`\[([^\]]+)\]\((https?://[^)\s]+)\)`) // Client talks to the release servers. @@ -148,6 +143,9 @@ func (c *Client) Latest(ctx context.Context) (Release, error) { return Release{}, errors.Join(errs...) } +// recentReleases is how many releases Latest reads the changelogs of. +const recentReleases = 10 + func (c *Client) latest(ctx context.Context, repo string) (Release, error) { api, err := API(repo) if err != nil {