refactor: isolate expensive IsDirty() call

See toolshed/abra#689
This commit is contained in:
2025-10-03 20:35:09 +02:00
parent 2460dd9438
commit d0ccb805c6
4 changed files with 14 additions and 14 deletions

View File

@ -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)