From 2460dd94380a60abfd442f3831ebbecbd536fcb9 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Fri, 3 Oct 2025 20:13:35 +0200 Subject: [PATCH 1/3] fix: pagination with multiline(true) See https://git.coopcloud.tech/toolshed/abra/issues/689 --- cli/app/list.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cli/app/list.go b/cli/app/list.go index 73839ff1..aeba022d 100644 --- a/cli/app/list.go +++ b/cli/app/list.go @@ -512,7 +512,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.table = msg.table m.table = m.table.WithTargetWidth(m.width) - m.table = m.table.WithPageSize(m.height - 10) + m.table = m.table.WithPageSize(calculateHeight(m)) if m.initStatusGather { m.pollingStatus = true @@ -526,7 +526,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.height = msg.Height m.table = m.table.WithTargetWidth(m.width) - m.table = m.table.WithPageSize(m.height - 10) + m.table = m.table.WithPageSize(calculateHeight(m)) case errorMsg: m.err = msg } @@ -540,6 +540,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Batch(cmds...) } +func calculateHeight(m model) int { + return m.height/2 - 5 +} + func (m model) View() string { if m.err != nil { return fmt.Sprintf("FATA: %v", m.err) @@ -554,7 +558,7 @@ func (m model) View() string { m.numFilteredServers, m.numFilteredApps, m.numFilteredRecipes, ) - help := "[q] quit • [/] filter • [s] status" + help := "[q] quit • [/] filter • [s] status • [ctrl+u/d] page up/down" body.WriteString(lipgloss.JoinHorizontal(lipgloss.Center, stats, " | ", help)) -- 2.49.0 From d0ccb805c6608f290cfa8864a8314531717408f7 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Fri, 3 Oct 2025 20:35:09 +0200 Subject: [PATCH 2/3] refactor: isolate expensive IsDirty() call See https://git.coopcloud.tech/toolshed/abra/issues/689 --- pkg/app/app.go | 11 +++++++---- pkg/recipe/git.go | 1 + pkg/recipe/git_test.go | 7 ++++++- pkg/recipe/recipe.go | 9 --------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/app/app.go b/pkg/app/app.go index a2ffe46a..a73a853d 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -644,6 +644,9 @@ func (a App) WriteRecipeVersion(version string, dryRun bool) error { scanner = bufio.NewScanner(file) ) + // NOTE(d1): don't care at this point if there is a git failure + isDirty, _ := a.Recipe.IsDirty() + for scanner.Scan() { line := scanner.Text() if !strings.HasPrefix(line, "RECIPE=") && !strings.HasPrefix(line, "TYPE=") { @@ -656,7 +659,7 @@ func (a App) WriteRecipeVersion(version string, dryRun bool) error { continue } - if strings.Contains(line, version) && !a.Recipe.Dirty && !strings.HasSuffix(line, config.DIRTY_DEFAULT) { + if strings.Contains(line, version) && !isDirty && !strings.HasSuffix(line, config.DIRTY_DEFAULT) { skipped = true lines = append(lines, line) continue @@ -669,16 +672,16 @@ func (a App) WriteRecipeVersion(version string, dryRun bool) error { } if err := scanner.Err(); err != nil { - log.Fatal(err) + return err } - if a.Recipe.Dirty && dirtyVersion != "" { + if isDirty && dirtyVersion != "" { version = dirtyVersion } if !dryRun { if err := os.WriteFile(a.Path, []byte(strings.Join(lines, "\n")), os.ModePerm); err != nil { - log.Fatal(err) + return err } } else { log.Debug(i18n.G("skipping writing version %s because dry run", version)) diff --git a/pkg/recipe/git.go b/pkg/recipe/git.go index e487e011..9eb03dbb 100644 --- a/pkg/recipe/git.go +++ b/pkg/recipe/git.go @@ -305,6 +305,7 @@ func (r *Recipe) ChaosVersion() (string, error) { if err != nil { return "", err } + if dirty { return fmt.Sprintf("%s%s", version, config.DIRTY_DEFAULT), nil } diff --git a/pkg/recipe/git_test.go b/pkg/recipe/git_test.go index 32197b83..22926a30 100644 --- a/pkg/recipe/git_test.go +++ b/pkg/recipe/git_test.go @@ -15,7 +15,12 @@ func TestIsDirty(t *testing.T) { t.Fatal(err) } - assert.False(t, r.Dirty) + isDirty, err := r.IsDirty() + if err != nil { + t.Fatal(err) + } + + assert.False(t, isDirty) fpath := filepath.Join(r.Dir, "foo.txt") f, err := os.Create(fpath) diff --git a/pkg/recipe/recipe.go b/pkg/recipe/recipe.go index 592e2452..0128a324 100644 --- a/pkg/recipe/recipe.go +++ b/pkg/recipe/recipe.go @@ -13,7 +13,6 @@ import ( "strings" "coopcloud.tech/abra/pkg/i18n" - "github.com/go-git/go-git/v5" "coopcloud.tech/abra/pkg/catalogue" "coopcloud.tech/abra/pkg/config" @@ -170,12 +169,6 @@ func Get(name string) Recipe { AbraShPath: path.Join(dir, "abra.sh"), } - dirty, err := r.IsDirty() - if err != nil && !errors.Is(err, git.ErrRepositoryNotExists) { - log.Fatal(i18n.G("failed to check git status of %s: %s", r.Name, err)) - } - r.Dirty = dirty - return r } @@ -183,7 +176,6 @@ type Recipe struct { Name string EnvVersion string EnvVersionRaw string - Dirty bool // NOTE(d1): git terminology for unstaged changes Dir string GitURL string SSHURL string @@ -198,7 +190,6 @@ type Recipe struct { func (r Recipe) String() string { out := i18n.G("{name: %s, ", r.Name) out += i18n.G("version : %s, ", r.EnvVersion) - out += i18n.G("dirty: %v, ", r.Dirty) out += i18n.G("dir: %s, ", r.Dir) out += i18n.G("git url: %s, ", r.GitURL) out += i18n.G("ssh url: %s, ", r.SSHURL) -- 2.49.0 From 7b4d2d72303dd8b176bf62c87fb29fac017f7d8a Mon Sep 17 00:00:00 2001 From: decentral1se Date: Fri, 3 Oct 2025 20:35:47 +0200 Subject: [PATCH 3/3] chore: make i18n --- pkg/i18n/locales/abra.pot | 82 ++++++++++++++---------------- pkg/i18n/locales/es.po | 102 +++++++++++++++++--------------------- 2 files changed, 82 insertions(+), 102 deletions(-) diff --git a/pkg/i18n/locales/abra.pot b/pkg/i18n/locales/abra.pot index 2112d3e4..d670a6d7 100644 --- a/pkg/i18n/locales/abra.pot +++ b/pkg/i18n/locales/abra.pot @@ -7,7 +7,7 @@ msgid "" msgstr "Project-Id-Version: \n" "Report-Msgid-Bugs-To: EMAIL\n" - "POT-Creation-Date: 2025-10-02 10:54+0200\n" + "POT-Creation-Date: 2025-10-03 20:35+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -411,7 +411,7 @@ msgstr "" msgid "%s sanitised as %s for new app" msgstr "" -#: ./pkg/recipe/git.go:434 +#: ./pkg/recipe/git.go:435 #, c-format msgid "%s service is missing image tag?" msgstr "" @@ -481,12 +481,12 @@ msgstr "" msgid "%s: ? (missing version)" msgstr "" -#: ./pkg/recipe/recipe.go:237 +#: ./pkg/recipe/recipe.go:228 #, c-format msgid "%s: attempt recipe metadata parse" msgstr "" -#: ./pkg/recipe/recipe.go:368 +#: ./pkg/recipe/recipe.go:359 #, c-format msgid "%s: end marker %s not found" msgstr "" @@ -501,17 +501,17 @@ msgstr "" msgid "%s: ignoring unsupported options: %s" msgstr "" -#: ./pkg/recipe/recipe.go:325 +#: ./pkg/recipe/recipe.go:316 #, c-format msgid "%s: image meta has incorrect format: %s" msgstr "" -#: ./pkg/recipe/recipe.go:330 +#: ./pkg/recipe/recipe.go:321 #, c-format msgid "%s: image meta is empty?" msgstr "" -#: ./pkg/recipe/recipe.go:361 +#: ./pkg/recipe/recipe.go:352 #, c-format msgid "%s: marker string %s not found" msgstr "" @@ -1740,7 +1740,7 @@ msgstr "" msgid "abra version: %s, commit: %s, lang: %s" msgstr "" -#: ./pkg/recipe/recipe.go:208 +#: ./pkg/recipe/recipe.go:199 #, c-format msgid "abra.sh: %s}" msgstr "" @@ -2107,7 +2107,7 @@ msgstr "" msgid "chk" msgstr "" -#: ./pkg/recipe/recipe.go:74 +#: ./pkg/recipe/recipe.go:73 #, c-format msgid "choosing %s as latest version of %s" msgstr "" @@ -2142,7 +2142,7 @@ msgstr "" msgid "cmd" msgstr "" -#: ./pkg/recipe/git.go:458 +#: ./pkg/recipe/git.go:459 #, c-format msgid "collected %s for %s" msgstr "" @@ -2156,7 +2156,7 @@ msgstr "" msgid "collecting metadata from %v servers: %s" msgstr "" -#: ./pkg/recipe/recipe.go:549 +#: ./pkg/recipe/recipe.go:540 msgid "collecting recipe listing" msgstr "" @@ -2203,7 +2203,7 @@ msgstr "" msgid "compose file contains unsupported options: %s" msgstr "" -#: ./pkg/recipe/recipe.go:205 +#: ./pkg/recipe/recipe.go:196 #, c-format msgid "compose: %s, " msgstr "" @@ -2468,7 +2468,7 @@ msgstr "" msgid "destination directory does not exist" msgstr "" -#: ./pkg/recipe/git.go:367 +#: ./pkg/recipe/git.go:368 #, c-format msgid "detected %s as tags for recipe %s" msgstr "" @@ -2487,7 +2487,7 @@ msgstr "" msgid "detected potential upgradable tags %s for %s" msgstr "" -#: ./pkg/recipe/recipe.go:435 +#: ./pkg/recipe/recipe.go:426 #, c-format msgid "detected versions %s for %s" msgstr "" @@ -2521,7 +2521,7 @@ msgstr "" msgid "different versions for secret '%s', '%s' and %s'" msgstr "" -#: ./pkg/recipe/recipe.go:202 +#: ./pkg/recipe/recipe.go:193 #, c-format msgid "dir: %s, " msgstr "" @@ -2531,11 +2531,6 @@ msgstr "" msgid "directory is empty: %s" msgstr "" -#: ./pkg/recipe/recipe.go:201 -#, c-format -msgid "dirty: %v, " -msgstr "" - #: ./cli/app/deploy.go:420 ./cli/app/rollback.go:368 ./cli/app/upgrade.go:478 msgid "disable converge logic checks" msgstr "" @@ -2787,12 +2782,7 @@ msgstr "" msgid "failed to add release notes: %s" msgstr "" -#: ./pkg/recipe/recipe.go:175 -#, c-format -msgid "failed to check git status of %s: %s" -msgstr "" - -#: ./pkg/git/branch.go:95 ./pkg/recipe/git.go:225 ./pkg/recipe/git.go:406 +#: ./pkg/git/branch.go:95 ./pkg/recipe/git.go:225 ./pkg/recipe/git.go:407 #, c-format msgid "failed to check out %s in %s" msgstr "" @@ -2987,7 +2977,7 @@ msgstr "" msgid "fetching latest recipes..." msgstr "" -#: ./pkg/recipe/recipe.go:555 +#: ./pkg/recipe/recipe.go:546 #, c-format msgid "fetching repo metadata from %s" msgstr "" @@ -3096,7 +3086,7 @@ msgstr "" msgid "git changes pushed" msgstr "" -#: ./pkg/recipe/git.go:410 +#: ./pkg/recipe/git.go:411 #, c-format msgid "git checkout: %s in %s" msgstr "" @@ -3154,7 +3144,7 @@ msgstr "" msgid "git tags pushed" msgstr "" -#: ./pkg/recipe/recipe.go:203 +#: ./pkg/recipe/recipe.go:194 #, c-format msgid "git url: %s, " msgstr "" @@ -3176,7 +3166,7 @@ msgstr "" msgid "git.coopcloud.tech repo exists" msgstr "" -#: ./pkg/recipe/git.go:378 +#: ./pkg/recipe/git.go:379 #, c-format msgid "git: opening repository in %s" msgstr "" @@ -3393,7 +3383,7 @@ msgstr "" msgid "invalid option %s for flag --resolve-image" msgstr "" -#: ./pkg/recipe/recipe.go:147 +#: ./pkg/recipe/recipe.go:146 #, c-format msgid "invalid recipe: %s" msgstr "" @@ -4086,7 +4076,7 @@ msgstr "" msgid "proceed?" msgstr "" -#: ./pkg/recipe/git.go:398 +#: ./pkg/recipe/git.go:399 #, c-format msgid "processing %s for %s" msgstr "" @@ -4181,7 +4171,7 @@ msgstr "" msgid "read global ignore paths: %s" msgstr "" -#: ./pkg/recipe/recipe.go:406 +#: ./pkg/recipe/recipe.go:397 #, c-format msgid "read recipe catalogue from file system cache in %s" msgstr "" @@ -4210,7 +4200,7 @@ msgstr "" msgid "reading secret from file: %s" msgstr "" -#: ./pkg/recipe/recipe.go:206 +#: ./pkg/recipe/recipe.go:197 #, c-format msgid "readme: %s, " msgstr "" @@ -4220,7 +4210,7 @@ msgstr "" msgid "recipe" msgstr "" -#: ./pkg/recipe/recipe.go:458 +#: ./pkg/recipe/recipe.go:449 #, c-format msgid "recipe %s does not exist?" msgstr "" @@ -4236,7 +4226,7 @@ msgstr "" msgid "recipe [cmd] [args] [flags]" msgstr "" -#: ./pkg/recipe/recipe.go:462 +#: ./pkg/recipe/recipe.go:453 #, c-format msgid "recipe metadata retrieved for %s" msgstr "" @@ -4309,7 +4299,7 @@ msgstr "" msgid "removed .git repo in %s" msgstr "" -#: ./pkg/recipe/recipe.go:138 +#: ./pkg/recipe/recipe.go:137 #, c-format msgid "removed dirty suffix from .env version: %s -> %s" msgstr "" @@ -4490,7 +4480,7 @@ msgstr "" msgid "retrieving docker auth token: failed create docker cli: %s" msgstr "" -#: ./pkg/recipe/recipe.go:659 +#: ./pkg/recipe/recipe.go:650 msgid "retrieving recipes" msgstr "" @@ -4605,7 +4595,7 @@ msgstr "" msgid "s" msgstr "" -#: ./pkg/recipe/recipe.go:207 +#: ./pkg/recipe/recipe.go:198 #, c-format msgid "sample env: %s, " msgstr "" @@ -4858,12 +4848,12 @@ msgstr "" msgid "skipping generation of %s (generate=false)" msgstr "" -#: ./pkg/app/app.go:690 +#: ./pkg/app/app.go:693 #, c-format msgid "skipping version %s write as already exists in %s.env" msgstr "" -#: ./pkg/app/app.go:684 +#: ./pkg/app/app.go:687 #, c-format msgid "skipping writing version %s because dry run" msgstr "" @@ -4913,7 +4903,7 @@ msgstr "" msgid "ssh host connection is not valid" msgstr "" -#: ./pkg/recipe/recipe.go:204 +#: ./pkg/recipe/recipe.go:195 #, c-format msgid "ssh url: %s, " msgstr "" @@ -5574,7 +5564,7 @@ msgstr "" msgid "version" msgstr "" -#: ./pkg/app/app.go:688 +#: ./pkg/app/app.go:691 #, c-format msgid "version %s saved to %s.env" msgstr "" @@ -5584,7 +5574,7 @@ msgstr "" msgid "version '%s' appears to be a chaos commit, but --chaos/-C was not provided" msgstr "" -#: ./pkg/recipe/recipe.go:200 +#: ./pkg/recipe/recipe.go:192 #, c-format msgid "version : %s, " msgstr "" @@ -5593,7 +5583,7 @@ msgstr "" msgid "version for abra" msgstr "" -#: ./pkg/recipe/recipe.go:130 +#: ./pkg/recipe/recipe.go:129 #, c-format msgid "version seems invalid: %s" msgstr "" @@ -5780,7 +5770,7 @@ msgstr "" msgid "{decoder: %v, " msgstr "" -#: ./pkg/recipe/recipe.go:199 +#: ./pkg/recipe/recipe.go:191 #, c-format msgid "{name: %s, " msgstr "" diff --git a/pkg/i18n/locales/es.po b/pkg/i18n/locales/es.po index 788236fb..2fd3df4f 100644 --- a/pkg/i18n/locales/es.po +++ b/pkg/i18n/locales/es.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: EMAIL\n" -"POT-Creation-Date: 2025-10-02 10:54+0200\n" +"POT-Creation-Date: 2025-10-03 20:35+0200\n" "PO-Revision-Date: 2025-09-04 08:14+0000\n" "Last-Translator: chasqui \n" "Language-Team: Spanish %s" msgstr "" @@ -4736,7 +4726,7 @@ msgstr "" msgid "retrieving docker auth token: failed create docker cli: %s" msgstr "" -#: pkg/recipe/recipe.go:659 +#: pkg/recipe/recipe.go:650 msgid "retrieving recipes" msgstr "" @@ -4856,7 +4846,7 @@ msgstr "" msgid "s" msgstr "" -#: pkg/recipe/recipe.go:207 +#: pkg/recipe/recipe.go:198 #, c-format msgid "sample env: %s, " msgstr "" @@ -4971,8 +4961,8 @@ msgstr "" #: cli/recipe/upgrade.go:228 #, c-format msgid "" -"service %s is at version %s, but pinned to %s, please correct your " -"compose.yml file manually!" +"service %s is at version %s, but pinned to %s, please correct your compose." +"yml file manually!" msgstr "" #: cli/recipe/upgrade.go:224 @@ -5112,12 +5102,12 @@ msgstr "" msgid "skipping generation of %s (generate=false)" msgstr "" -#: pkg/app/app.go:690 +#: pkg/app/app.go:693 #, c-format msgid "skipping version %s write as already exists in %s.env" msgstr "" -#: pkg/app/app.go:684 +#: pkg/app/app.go:687 #, c-format msgid "skipping writing version %s because dry run" msgstr "" @@ -5167,7 +5157,7 @@ msgstr "" msgid "ssh host connection is not valid" msgstr "" -#: pkg/recipe/recipe.go:204 +#: pkg/recipe/recipe.go:195 #, c-format msgid "ssh url: %s, " msgstr "" @@ -5841,7 +5831,7 @@ msgstr "" msgid "version" msgstr "" -#: pkg/app/app.go:688 +#: pkg/app/app.go:691 #, c-format msgid "version %s saved to %s.env" msgstr "" @@ -5852,7 +5842,7 @@ msgid "" "version '%s' appears to be a chaos commit, but --chaos/-C was not provided" msgstr "" -#: pkg/recipe/recipe.go:200 +#: pkg/recipe/recipe.go:192 #, c-format msgid "version : %s, " msgstr "" @@ -5861,7 +5851,7 @@ msgstr "" msgid "version for abra" msgstr "" -#: pkg/recipe/recipe.go:130 +#: pkg/recipe/recipe.go:129 #, c-format msgid "version seems invalid: %s" msgstr "" @@ -6052,7 +6042,7 @@ msgstr "" msgid "{decoder: %v, " msgstr "" -#: pkg/recipe/recipe.go:199 +#: pkg/recipe/recipe.go:191 #, c-format msgid "{name: %s, " msgstr "" -- 2.49.0