Skip to content
This repository was archived by the owner on Dec 18, 2020. It is now read-only.

Commit

Permalink
Use TrimSuffix instead of TrimRight to extract the repository path from
Browse files Browse the repository at this point in the history
the path of the git folder
  • Loading branch information
Ekans committed Apr 16, 2016
1 parent 98290e5 commit b1d2085
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func CheckGitRepos(repos []string, err error) ([]string, error) {
}

for i, repo := range repos {
repos[i] = strings.TrimRight(repo, "/.git")
repos[i] = strings.TrimSuffix(repo, "/.git")
}

return repos, nil
Expand Down
27 changes: 27 additions & 0 deletions core/core_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package core

import (
"reflect"
"testing"
)

func TestCheckGitRepos(t *testing.T) {
cases := []testReposAreValid{
{[]string{"repo1"}, []string{"repo1"}},
{[]string{"bash-git-prompt"}, []string{"bash-git-prompt"}},
}
for _, data := range cases {
result, err := CheckGitRepos(data.repos, nil)
if err != nil {
t.Errorf("Failed to check Git repos (%q) == %q, expected %q", data.repos, result, data.result)
}
if !reflect.DeepEqual(result, data.result) {
t.Errorf("Failed to check Git repos (%q) == %q, expected %q", data.repos, result, data.result)
}
}
}

type testReposAreValid struct {
repos []string
result []string
}

0 comments on commit b1d2085

Please sign in to comment.