Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
internal/fs: rename EqualPaths to EquivalentPaths
Browse files Browse the repository at this point in the history
Signed-off-by: Ibrahim AshShohail <[email protected]>
  • Loading branch information
ibrasho committed Aug 9, 2017
1 parent 08af070 commit b60c5a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (c *Ctx) DetectProjectGOPATH(p *Project) (string, error) {
pGOPATH, perr := c.detectGOPATH(p.AbsRoot)

// If p.AbsRoot is a not symlink, attempt to detect GOPATH for p.AbsRoot only.
if equal, _ := fs.EqualPaths(p.AbsRoot, p.ResolvedAbsRoot); equal {
if equal, _ := fs.EquivalentPaths(p.AbsRoot, p.ResolvedAbsRoot); equal {
return pGOPATH, perr
}

Expand All @@ -191,7 +191,7 @@ func (c *Ctx) DetectProjectGOPATH(p *Project) (string, error) {
}

// If pGOPATH equals rGOPATH, then both are within the same GOPATH.
if equal, _ := fs.EqualPaths(pGOPATH, rGOPATH); equal {
if equal, _ := fs.EquivalentPaths(pGOPATH, rGOPATH); equal {
return "", errors.Errorf("both %s and %s are in the same GOPATH %s", p.AbsRoot, p.ResolvedAbsRoot, pGOPATH)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ func HasFilepathPrefix(path, prefix string) bool {
return true
}

// EqualPaths compares the paths passed to check if the are equivalent.
// EquivalentPaths compares the paths passed to check if the are equivalent.
// It respects the case-sensitivity of the underlaying filesysyems.
func EqualPaths(p1, p2 string) (bool, error) {
func EquivalentPaths(p1, p2 string) (bool, error) {
p1 = filepath.Clean(p1)
p2 = filepath.Clean(p2)

Expand Down
8 changes: 4 additions & 4 deletions internal/fs/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func TestHasFilepathPrefix_Files(t *testing.T) {
}
}

func TestEqualPaths(t *testing.T) {
func TestEquivalentPaths(t *testing.T) {
h := test.NewHelper(t)
h.TempDir("dir")
h.TempDir("dir2")
Expand Down Expand Up @@ -166,17 +166,17 @@ func TestEqualPaths(t *testing.T) {
}

for _, tc := range testcases {
got, err := EqualPaths(tc.p1, tc.p2)
got, err := EquivalentPaths(tc.p1, tc.p2)
if err != nil && !tc.err {
t.Error("unexpected error:", err)
}
if caseSensitive {
if tc.caseSensitiveEquivalent != got {
t.Errorf("expected EqualPaths(%q, %q) to be %t on case-sensitive filesystem, got %t", tc.p1, tc.p2, tc.caseSensitiveEquivalent, got)
t.Errorf("expected EquivalentPaths(%q, %q) to be %t on case-sensitive filesystem, got %t", tc.p1, tc.p2, tc.caseSensitiveEquivalent, got)
}
} else {
if tc.caseInensitiveEquivalent != got {
t.Errorf("expected EqualPaths(%q, %q) to be %t on case-insensitive filesystem, got %t", tc.p1, tc.p2, tc.caseInensitiveEquivalent, got)
t.Errorf("expected EquivalentPaths(%q, %q) to be %t on case-insensitive filesystem, got %t", tc.p1, tc.p2, tc.caseInensitiveEquivalent, got)
}
}
}
Expand Down

0 comments on commit b60c5a9

Please sign in to comment.