diff --git a/.github/workflows/test_release.yml b/.github/workflows/test_release.yml index d858b85..7160b2f 100644 --- a/.github/workflows/test_release.yml +++ b/.github/workflows/test_release.yml @@ -46,6 +46,12 @@ jobs: run: | make test + - name: test (different LOCALE) + if: runner.os == 'Linux' + run: | + sudo locale-gen zh_CN.UTF-8 + LC_ALL='zh_CN.UTF-8' make test + release: if: (github.ref == 'refs/heads/main') && (github.repository_owner == 'mikesmithgh') diff --git a/main.go b/main.go index 3aec3a3..3054002 100644 --- a/main.go +++ b/main.go @@ -175,12 +175,12 @@ func main() { util.ErrMsg("color reset", err) } - gitRepo, stderr, err := git.RevParse() + gitRepo, _, err := git.RevParse() if err != nil { switch { case strings.Contains(err.Error(), exec.ErrNotFound.Error()): util.ErrMsg("rev parse", err) - case strings.Contains(string(stderr), "not a git repository"): + case gitRepo.IsInGitDir == nil: os.Exit(0) default: // allow other errors to pass through, the git repo may not have upstream diff --git a/pkg/git/git.go b/pkg/git/git.go index 872eeba..fc6e32c 100644 --- a/pkg/git/git.go +++ b/pkg/git/git.go @@ -191,7 +191,8 @@ func RevParse() (*GitRepo, []byte, error) { resultLen := len(result) if resultLen == 5 || resultLen == 6 { g.GitDir = result[0] - g.IsInGitDir, _ = strconv.ParseBool(result[1]) + isInGitDir, _ := strconv.ParseBool(result[1]) + g.IsInGitDir = &isInGitDir g.IsInWorkTree, _ = strconv.ParseBool(result[2]) g.IsInBareRepo, _ = strconv.ParseBool(result[3]) g.IsInShallowRepo, _ = strconv.ParseBool(result[4]) diff --git a/pkg/git/repo.go b/pkg/git/repo.go index 48b78ed..23916af 100644 --- a/pkg/git/repo.go +++ b/pkg/git/repo.go @@ -13,7 +13,7 @@ import ( type GitRepo struct { GitDir string - IsInGitDir bool + IsInGitDir *bool // pointer is used during checks if in a git repo IsInWorkTree bool IsInBareRepo bool IsInShallowRepo bool @@ -155,7 +155,7 @@ func (g *GitRepo) BranchInfo(cfg config.GitPromptStringConfig) (string, error) { } } - if g.IsInGitDir { + if *g.IsInGitDir { if g.IsInBareRepo { g.PromptBareRepoStatus = "BARE:" } else { @@ -201,7 +201,7 @@ func (g *GitRepo) BranchStatus(cfg config.GitPromptStringConfig) (string, string status := "" statusColor := "" - if g.IsInBareRepo || g.IsInGitDir { + if g.IsInBareRepo || *g.IsInGitDir { return status, cfg.ColorNoUpstream, nil }