mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	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:
		| @@ -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 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Lunny Xiao
					Lunny Xiao