WIP: feat: translation support
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
See #483
This commit is contained in:
@ -2,13 +2,13 @@ package git
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/go-git/go-git/v5"
|
||||
gitConfigPkg "github.com/go-git/go-git/v5/config"
|
||||
@ -23,12 +23,12 @@ func IsClean(repoPath string) (bool, error) {
|
||||
return false, git.ErrRepositoryNotExists
|
||||
}
|
||||
|
||||
return false, fmt.Errorf("unable to open %s: %s", repoPath, err)
|
||||
return false, errors.New(i18n.G("unable to open %s: %s", repoPath, err))
|
||||
}
|
||||
|
||||
worktree, err := repo.Worktree()
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("unable to open worktree of %s: %s", repoPath, err)
|
||||
return false, errors.New(i18n.G("unable to open worktree of %s: %s", repoPath, err))
|
||||
}
|
||||
|
||||
patterns, err := GetExcludesFiles()
|
||||
@ -42,14 +42,14 @@ func IsClean(repoPath string) (bool, error) {
|
||||
|
||||
status, err := worktree.Status()
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("unable to query status of %s: %s", repoPath, err)
|
||||
return false, errors.New(i18n.G("unable to query status of %s: %s", repoPath, err))
|
||||
}
|
||||
|
||||
if status.String() != "" {
|
||||
noNewline := strings.TrimSuffix(status.String(), "\n")
|
||||
log.Debugf("git status: %s: %s", repoPath, noNewline)
|
||||
log.Debug(i18n.G("git status: %s: %s", repoPath, noNewline))
|
||||
} else {
|
||||
log.Debugf("git status: %s: clean", repoPath)
|
||||
log.Debug(i18n.G("git status: %s: clean", repoPath))
|
||||
}
|
||||
|
||||
return status.IsClean(), nil
|
||||
@ -85,7 +85,7 @@ func parseGitConfig() (*gitConfigPkg.Config, error) {
|
||||
globalGitConfig := filepath.Join(usr.HomeDir, ".gitconfig")
|
||||
if _, err := os.Stat(globalGitConfig); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
log.Debugf("no %s exists, not reading any global gitignore config", globalGitConfig)
|
||||
log.Debug(i18n.G("no %s exists, not reading any global gitignore config", globalGitConfig))
|
||||
return cfg, nil
|
||||
}
|
||||
return cfg, err
|
||||
@ -127,7 +127,7 @@ func parseExcludesFile(excludesfile string) ([]gitignore.Pattern, error) {
|
||||
|
||||
if _, err := os.Stat(excludesfile); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
log.Debugf("no %s exists, skipping reading gitignore paths", excludesfile)
|
||||
log.Debug(i18n.G("no %s exists, skipping reading gitignore paths", excludesfile))
|
||||
return ps, nil
|
||||
}
|
||||
return ps, err
|
||||
@ -146,7 +146,7 @@ func parseExcludesFile(excludesfile string) ([]gitignore.Pattern, error) {
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("read global ignore paths: %s", strings.Join(pathsRaw, " "))
|
||||
log.Debug(i18n.G("read global ignore paths: %s", strings.Join(pathsRaw, " ")))
|
||||
|
||||
return ps, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user