diff --git a/.github/workflows/test_release.yml b/.github/workflows/test_release.yml index 8e13bd6..5fb8c04 100644 --- a/.github/workflows/test_release.yml +++ b/.github/workflows/test_release.yml @@ -87,5 +87,5 @@ jobs: npm install @semantic-release/git @semantic-release/changelog @semantic-release/exec -D npx semantic-release env: - GH_TOKEN: ${{ secrets.BGPS_CI_TOKEN }} - GITHUB_TOKEN: ${{ secrets.BGPS_CI_TOKEN }} + GH_TOKEN: ${{ secrets.GIT_PROMPT_STRING_CI_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GIT_PROMPT_STRING_CI_TOKEN }} diff --git a/.gitignore b/.gitignore index bf347d3..e02573c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ dist/ node_modules/ package-lock.json package.json +git-prompt-string +git-prompt-string.exe diff --git a/Makefile b/Makefile index 113f491..4487102 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ help: @echo "==> describe make commands" @echo "" - @echo "build ==> build bgps for current GOOS and GOARCH" + @echo "build ==> build binary for current GOOS and GOARCH" @echo "test ==> run tests" .PHONY: build diff --git a/README.md b/README.md index e2a7156..443ac3c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Better Git Prompt String +# 📍 git-prompt-string > [!WARNING]\ -> 03/20/2024: bgps is actively undergoing a major v2 rewrite in ![go](https://img.shields.io/badge/Go-00ADD8?style=flat-square&logo=go&logoColor=white) +> 03/20/2024: git-prompt-string (previously bgps) is actively undergoing a major v2 rewrite in ![go](https://img.shields.io/badge/Go-00ADD8?style=flat-square&logo=go&logoColor=white) > -> This is a breaking change that will simplify and improve maintainability of bgps +> This is a breaking change that will simplify and improve maintainability of git-prompt-string > > If you prefer to keep using legacy bgps, then use the tag [v1.0.0](https://github.com/mikesmithgh/bgps/releases/tag/v1.0.0) diff --git a/go.mod b/go.mod index 7415c18..38fb4fc 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/mikesmithgh/bgps +module github.com/mikesmithgh/git-prompt-string go 1.22.0 diff --git a/integration/bgps_test.go b/integration/gps_test.go similarity index 88% rename from integration/bgps_test.go rename to integration/gps_test.go index c80e635..6f5d447 100644 --- a/integration/bgps_test.go +++ b/integration/gps_test.go @@ -9,7 +9,7 @@ import ( "testing" ) -func TestBGPS(t *testing.T) { +func TestGPS(t *testing.T) { var notFoundMsg string if runtime.GOOS == "windows" { notFoundMsg = "The system cannot find the path specified." @@ -72,13 +72,13 @@ func TestBGPS(t *testing.T) { {"dirty", []string{"--config=../configs/color_overrides.toml"}, "\x1b[48;2;179;5;89m \ue0a0 main *\x1b[0m", nil}, {"conflict_ahead", []string{"--config=../configs/color_overrides.toml"}, "\x1b[38;2;252;183;40m \ue0a0 main ↑[1]\x1b[0m", nil}, {"untracked", []string{"--config=../configs/color_overrides.toml"}, "\x1b[38;2;255;0;0m\x1b[48;2;22;242;170m \ue0a0 main *\x1b[0m", nil}, - {"bisect", []string{}, "\x1b[48;2;204;204;255m\x1b[35m \ue0a0 main|BISECTING ↓[1]\x1b[0m", []string{"BGPS_CONFIG=../configs/color_overrides.toml"}}, + {"bisect", []string{}, "\x1b[48;2;204;204;255m\x1b[35m \ue0a0 main|BISECTING ↓[1]\x1b[0m", []string{"GIT_PROMPT_STRING_CONFIG=../configs/color_overrides.toml"}}, // config errors - {"clean", []string{"--config=/fromparam/does/not/exist"}, fmt.Sprintf("\x1b[31m bgps error(read config): open /fromparam/does/not/exist: %s\x1b[0m", notFoundMsg), nil}, - {"configs", []string{}, fmt.Sprintf("\x1b[31m bgps error(read config): open /fromenvvar/does/not/exist: %s\x1b[0m", notFoundMsg), []string{"BGPS_CONFIG=/fromenvvar/does/not/exist"}}, - {"configs", []string{"--config=invalid_syntax.toml"}, "\x1b[31m bgps error(unmarshal config): toml: expected character =\x1b[0m", nil}, - {"configs", []string{}, "\x1b[31m bgps error(unmarshal config): toml: expected character =\x1b[0m", []string{"BGPS_CONFIG=invalid_syntax.toml"}}, + {"clean", []string{"--config=/fromparam/does/not/exist"}, fmt.Sprintf("\x1b[31m git-prompt-string error(read config): open /fromparam/does/not/exist: %s\x1b[0m", notFoundMsg), nil}, + {"configs", []string{}, fmt.Sprintf("\x1b[31m git-prompt-string error(read config): open /fromenvvar/does/not/exist: %s\x1b[0m", notFoundMsg), []string{"GIT_PROMPT_STRING_CONFIG=/fromenvvar/does/not/exist"}}, + {"configs", []string{"--config=invalid_syntax.toml"}, "\x1b[31m git-prompt-string error(unmarshal config): toml: expected character =\x1b[0m", nil}, + {"configs", []string{}, "\x1b[31m git-prompt-string error(unmarshal config): toml: expected character =\x1b[0m", []string{"GIT_PROMPT_STRING_CONFIG=invalid_syntax.toml"}}, {"norepo", []string{"--config=NONE"}, "", nil}, } diff --git a/integration/init_test.go b/integration/init_test.go index 693f77a..8d5f5f4 100644 --- a/integration/init_test.go +++ b/integration/init_test.go @@ -22,16 +22,16 @@ func TestMain(m *testing.M) { } defer os.RemoveAll(tmpDir) - bgps := "bgps" + gps := "git-prompt-string" if runtime.GOOS == "windows" { - bgps += ".exe" + gps += ".exe" } - builtBinaryPath = filepath.Join(tmpDir, bgps) + builtBinaryPath = filepath.Join(tmpDir, gps) cmd := exec.Command("go", "build", "-o", builtBinaryPath, "..") output, err := cmd.CombinedOutput() if err != nil { - panic(fmt.Sprintf("failed to build bgps: %s, %s", output, err)) + panic(fmt.Sprintf("failed to build gps: %s, %s", output, err)) } cmd = exec.Command("cp", "-r", "../testdata", tmpDir) diff --git a/main.go b/main.go index 7a09f6c..ebbd459 100644 --- a/main.go +++ b/main.go @@ -8,10 +8,10 @@ import ( "runtime" "strings" - "github.com/mikesmithgh/bgps/pkg/color" - "github.com/mikesmithgh/bgps/pkg/config" - "github.com/mikesmithgh/bgps/pkg/git" - "github.com/mikesmithgh/bgps/pkg/util" + "github.com/mikesmithgh/git-prompt-string/pkg/color" + "github.com/mikesmithgh/git-prompt-string/pkg/config" + "github.com/mikesmithgh/git-prompt-string/pkg/git" + "github.com/mikesmithgh/git-prompt-string/pkg/util" "github.com/pelletier/go-toml/v2" ) @@ -33,7 +33,7 @@ var ( ) func main() { - cfg := config.BgpsConfig{ + cfg := config.GPSConfig{ PromptPrefix: *promptPrefix, PromptSuffix: *promptSuffix, AheadFormat: *aheadFormat, @@ -51,14 +51,14 @@ func main() { flag.Parse() - var bgpsConfigPath string - bgpsConfigEnv := os.Getenv("BGPS_CONFIG") + var gpsConfig string + gpsConfigEnv := os.Getenv("GIT_PROMPT_STRING_CONFIG") if *configPath == "" { - bgpsConfigPath = bgpsConfigEnv + gpsConfig = gpsConfigEnv } else { - bgpsConfigPath = *configPath + gpsConfig = *configPath } - if bgpsConfigPath == "" { + if gpsConfig == "" { xdgConfigHome := os.Getenv("XDG_CONFIG_HOME") if xdgConfigHome == "" { home, err := os.UserHomeDir() @@ -71,20 +71,20 @@ func main() { xdgConfigHome = path.Join(home, ".config") } } - bgpsConfigPath = path.Join(xdgConfigHome, "bgps", "config.toml") + gpsConfig = path.Join(xdgConfigHome, "git-prompt-string", "config.toml") } - if bgpsConfigPath != "NONE" { - bgpsConfigRaw, err := os.ReadFile(bgpsConfigPath) + if gpsConfig != "NONE" { + gpsConfigRaw, err := os.ReadFile(gpsConfig) if err != nil && !os.IsNotExist(err) { util.ErrMsg("read config exists", err, 0) } - if err != nil && (*configPath != "" || bgpsConfigEnv != "") { + if err != nil && (*configPath != "" || gpsConfigEnv != "") { util.ErrMsg("read config", err, 0) } - err = toml.Unmarshal(bgpsConfigRaw, &cfg) + err = toml.Unmarshal(gpsConfigRaw, &cfg) if err != nil { util.ErrMsg("unmarshal config", err, 0) } diff --git a/pkg/config/config.go b/pkg/config/config.go index 881809a..3577a30 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1,6 +1,6 @@ package config -type BgpsConfig struct { +type GPSConfig struct { PromptPrefix string `toml:"prompt_prefix"` PromptSuffix string `toml:"prompt_suffix"` AheadFormat string `toml:"ahead_format"` diff --git a/pkg/git/repo.go b/pkg/git/repo.go index 1ebf47e..9dd43e1 100644 --- a/pkg/git/repo.go +++ b/pkg/git/repo.go @@ -7,9 +7,9 @@ import ( "path/filepath" "strings" - "github.com/mikesmithgh/bgps/pkg/color" - "github.com/mikesmithgh/bgps/pkg/config" - "github.com/mikesmithgh/bgps/pkg/util" + "github.com/mikesmithgh/git-prompt-string/pkg/color" + "github.com/mikesmithgh/git-prompt-string/pkg/config" + "github.com/mikesmithgh/git-prompt-string/pkg/util" ) type GitRepo struct { @@ -71,7 +71,7 @@ func (g *GitRepo) ReadGitDirFileExitOnError(name string) string { return content } -func (g *GitRepo) BranchInfo(cfg config.BgpsConfig) (string, error) { +func (g *GitRepo) BranchInfo(cfg config.GPSConfig) (string, error) { var err error ref := "" step := "" @@ -190,7 +190,7 @@ func (g *GitRepo) BranchInfo(cfg config.BgpsConfig) (string, error) { return prompt, nil } -func (g *GitRepo) BranchStatus(cfg config.BgpsConfig) (string, string, error) { +func (g *GitRepo) BranchStatus(cfg config.GPSConfig) (string, string, error) { status := "" statusColor := "" diff --git a/pkg/util/util.go b/pkg/util/util.go index f9e5ebb..c8f1862 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -6,7 +6,7 @@ import ( "os" "strings" - "github.com/mikesmithgh/bgps/pkg/color" + "github.com/mikesmithgh/git-prompt-string/pkg/color" ) func IsDir(name string) bool { @@ -42,6 +42,6 @@ func ErrMsg(hint string, e error, exitCode int) { } else { error_msg = strings.ReplaceAll(strings.ReplaceAll(e.Error(), "\n", ""), "\r", "") } - fmt.Printf("%s bgps error(%s): %s%s", errorColor, hint, error_msg, clearColor) + fmt.Printf("%s git-prompt-string error(%s): %s%s", errorColor, hint, error_msg, clearColor) os.Exit(exitCode) }