Move duplicated functions (#33977)

Remove duplicated functions `IsExist`, `IsFile` and `IsDir` in package
`modules/git` and use the exists functions in `modules/util`.
This commit is contained in:
Lunny Xiao
2025-03-25 07:40:31 -07:00
committed by GitHub
parent 356b707dde
commit d6e94fa4e4
4 changed files with 35 additions and 35 deletions

View File

@ -8,7 +8,6 @@ import (
"encoding/hex"
"fmt"
"io"
"os"
"strconv"
"strings"
"sync"
@ -41,33 +40,6 @@ func (oc *ObjectCache[T]) Get(id string) (T, bool) {
return obj, has
}
// isDir returns true if given path is a directory,
// or returns false when it's a file or does not exist.
func isDir(dir string) bool {
f, e := os.Stat(dir)
if e != nil {
return false
}
return f.IsDir()
}
// isFile returns true if given path is a file,
// or returns false when it's a directory or does not exist.
func isFile(filePath string) bool {
f, e := os.Stat(filePath)
if e != nil {
return false
}
return !f.IsDir()
}
// isExist checks whether a file or directory exists.
// It returns false when the file or directory does not exist.
func isExist(path string) bool {
_, err := os.Stat(path)
return err == nil || os.IsExist(err)
}
// ConcatenateError concatenats an error with stderr string
func ConcatenateError(err error, stderr string) error {
if len(stderr) == 0 {