mirror of
https://github.com/grdl/git-get.git
synced 2026-03-23 00:20:07 +00:00
Replace deprecated modules
Replace go-homedir with builtin os.UserHomeDir and pkg/errors with builtin errors
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -9,7 +10,6 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/karrick/godirwalk"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Max number of concurrently running status loading workers.
|
||||
@@ -32,12 +32,12 @@ func Exists(path string) (bool, error) {
|
||||
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return false, errors.Wrapf(errDirNotExist, "can't access %s", path)
|
||||
return false, fmt.Errorf("can't access %s: %w", path, errDirNotExist)
|
||||
}
|
||||
}
|
||||
|
||||
// Directory exists but can't be accessed
|
||||
return true, errors.Wrapf(errDirNoAccess, "can't access %s", path)
|
||||
return true, fmt.Errorf("can't access %s: %w", path, errDirNoAccess)
|
||||
}
|
||||
|
||||
// RepoFinder finds git repositories inside a given path and loads their status.
|
||||
|
||||
@@ -45,7 +45,6 @@ func TestFinder(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: this test will only work on Linux
|
||||
func TestExists(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -56,10 +55,6 @@ func TestExists(t *testing.T) {
|
||||
name: "dir does not exist",
|
||||
path: "/this/directory/does/not/exist",
|
||||
want: errDirNotExist,
|
||||
}, {
|
||||
name: "dir cant be accessed",
|
||||
path: "/root/some/directory",
|
||||
want: errDirNoAccess,
|
||||
}, {
|
||||
name: "dir exists",
|
||||
path: "/tmp/",
|
||||
|
||||
Reference in New Issue
Block a user