MCPcopy
hub / github.com/jesseduffield/lazygit / CopyFile

Method CopyFile

pkg/integration/components/shell.go:478–510  ·  view source on GitHub ↗
(source string, destination string)

Source from the content-addressed store, hash-verified

476}
477
478func (self *Shell) CopyFile(source string, destination string) *Shell {
479 absSourcePath := filepath.Join(self.dir, source)
480 absDestPath := filepath.Join(self.dir, destination)
481 sourceFile, err := os.Open(absSourcePath)
482 if err != nil {
483 self.fail(err.Error())
484 }
485 defer sourceFile.Close()
486
487 destinationFile, err := os.Create(absDestPath)
488 if err != nil {
489 self.fail(err.Error())
490 }
491 defer destinationFile.Close()
492
493 _, err = io.Copy(destinationFile, sourceFile)
494 if err != nil {
495 self.fail(err.Error())
496 }
497
498 // copy permissions to destination file too
499 sourceFileInfo, err := os.Stat(absSourcePath)
500 if err != nil {
501 self.fail(err.Error())
502 }
503
504 err = os.Chmod(absDestPath, sourceFileInfo.Mode())
505 if err != nil {
506 self.fail(err.Error())
507 }
508
509 return self
510}
511
512// The final value passed to Chdir() during setup
513// will be the directory the test is run from.

Callers 1

CopyHelpFileMethod · 0.95

Calls 5

OpenMethod · 0.80
failMethod · 0.80
ErrorMethod · 0.45
CloseMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected