detached 905294c

refactor(config): use strings.HasSuffix and filepath.Base for cleaner code

commit
905294c746f54a84969d84d6c3c9d3d72f2e27e9
author
bnema · · 2025-12-27 19:13 UTC
parent
10db773
signature
GPG Unverified2B82207D370127A0 The key is unknown
2 files · +3 -3
M internal/cli/styles/config.go +2 -2
@@ -2,6 +2,7 @@ package styles
22
33 import (
44 "fmt"
5+ "path/filepath"
56 "strings"
67
78 "github.com/charmbracelet/lipgloss"
@@ -75,8 +76,7 @@ func (r *ConfigRenderer) RenderMigrationSuccess(count int, path string) string {
7576 pathStyle := r.theme.Subtle
7677
7778 // Get just the filename from the path
78- parts := strings.Split(path, "/")
79- filename := parts[len(parts)-1]
79+ filename := filepath.Base(path)
8080
8181 return fmt.Sprintf(
8282 "\n %s Added %s new settings to %s\n",
@@ -2,6 +2,7 @@ package styles
2 2
3 import (3 import (
4 "fmt"4 "fmt"
5+ "path/filepath"
5 "strings"6 "strings"
6 7
7 "github.com/charmbracelet/lipgloss"8 "github.com/charmbracelet/lipgloss"
@@ -75,8 +76,7 @@ func (r *ConfigRenderer) RenderMigrationSuccess(count int, path string) string {
75 pathStyle := r.theme.Subtle76 pathStyle := r.theme.Subtle
76 77
77 // Get just the filename from the path78 // Get just the filename from the path
78- parts := strings.Split(path, "/")79+ filename := filepath.Base(path)
79- filename := parts[len(parts)-1]
80 80
81 return fmt.Sprintf(81 return fmt.Sprintf(
82 "\n %s Added %s new settings to %s\n",82 "\n %s Added %s new settings to %s\n",
M internal/infrastructure/config/migrate.go +1 -1
@@ -199,7 +199,7 @@ func (*Migrator) isUserDataSection(keyPath string) bool {
199199 }
200200
201201 for _, suffix := range userDataSuffixes {
202- if len(keyPath) > len(suffix) && keyPath[len(keyPath)-len(suffix):] == suffix {
202+ if strings.HasSuffix(keyPath, suffix) {
203203 return true
204204 }
205205 }
@@ -199,7 +199,7 @@ func (*Migrator) isUserDataSection(keyPath string) bool {
199 }199 }
200 200
201 for _, suffix := range userDataSuffixes {201 for _, suffix := range userDataSuffixes {
202- if len(keyPath) > len(suffix) && keyPath[len(keyPath)-len(suffix):] == suffix {202+ if strings.HasSuffix(keyPath, suffix) {
203 return true203 return true
204 }204 }
205 }205 }

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