mirror of https://github.com/knative/func.git
fix: repo add skips root (#1577)
This commit is contained in:
parent
726b566f83
commit
91c95a711e
|
@ -252,18 +252,14 @@ func (m maskingFS) Readlink(link string) (string, error) {
|
|||
// CopyFromFS copies files from the `src` dir on the accessor Filesystem to local filesystem into `dest` dir.
|
||||
// The src path uses slashes as their separator.
|
||||
// The dest path uses OS specific separator.
|
||||
func CopyFromFS(src, dest string, accessor Filesystem) (err error) {
|
||||
|
||||
return fs.WalkDir(accessor, src, func(path string, de fs.DirEntry, err error) error {
|
||||
func CopyFromFS(root, dest string, fsys Filesystem) (err error) {
|
||||
// Walks the filesystem rooted at root.
|
||||
return fs.WalkDir(fsys, root, func(path string, de fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if path == src {
|
||||
return nil
|
||||
}
|
||||
|
||||
p, err := filepath.Rel(filepath.FromSlash(src), filepath.FromSlash(path))
|
||||
p, err := filepath.Rel(filepath.FromSlash(root), filepath.FromSlash(path))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -280,7 +276,7 @@ func CopyFromFS(src, dest string, accessor Filesystem) (err error) {
|
|||
return os.MkdirAll(dest, 0755)
|
||||
case de.Type()&fs.ModeSymlink != 0:
|
||||
var symlinkTarget string
|
||||
symlinkTarget, err = accessor.Readlink(path)
|
||||
symlinkTarget, err = fsys.Readlink(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -296,7 +292,7 @@ func CopyFromFS(src, dest string, accessor Filesystem) (err error) {
|
|||
}
|
||||
defer destFile.Close()
|
||||
|
||||
srcFile, err := accessor.Open(path)
|
||||
srcFile, err := fsys.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -498,7 +498,7 @@ func (r *Repository) Runtime(name string) (runtime Runtime, err error) {
|
|||
}
|
||||
|
||||
// Write all files in the repository to the given path.
|
||||
func (r *Repository) Write(path string) (err error) {
|
||||
func (r *Repository) Write(dest string) (err error) {
|
||||
if r.fs == nil {
|
||||
return errors.New("the write operation is not supported on this repo")
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ func (r *Repository) Write(path string) (err error) {
|
|||
}
|
||||
fs = filesystem.NewBillyFilesystem(wt.Filesystem)
|
||||
}
|
||||
return filesystem.CopyFromFS(".", path, fs)
|
||||
return filesystem.CopyFromFS(".", dest, fs)
|
||||
}
|
||||
|
||||
// URL attempts to read the remote git origin URL of the repository. Best
|
||||
|
|
Loading…
Reference in New Issue