Handles the process of checking out a single file, and updating the git index. Note that the current working directory will be changed to the root of the working tree, unless no work tree exists (e.g., the repository is bare and GIT_WORK_TREE is not defined), in which case Run() is a no-op.
(gitEnv config.Environment, remote string)
| 23 | // of the working tree, unless no work tree exists (e.g., the repository |
| 24 | // is bare and GIT_WORK_TREE is not defined), in which case Run() is a no-op. |
| 25 | func newSingleCheckout(gitEnv config.Environment, remote string) abstractCheckout { |
| 26 | clean, ok := gitEnv.Get("filter.lfs.clean") |
| 27 | if !ok || len(clean) == 0 { |
| 28 | return &noOpCheckout{remote: remote} |
| 29 | } |
| 30 | |
| 31 | workingDir := cfg.LocalWorkingDir() |
| 32 | hasWorkTree := workingDir != "" |
| 33 | if hasWorkTree { |
| 34 | if err := os.Chdir(workingDir); err != nil { |
| 35 | FullError(errors.Wrap(err, tr.Tr.Get("Checkout error trying to change directory: %s", workingDir))) |
| 36 | hasWorkTree = false |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | return &singleCheckout{ |
| 41 | gitIndexer: &gitIndexer{}, |
| 42 | hasWorkTree: hasWorkTree, |
| 43 | manifest: nil, |
| 44 | remote: remote, |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | type abstractCheckout interface { |
| 49 | Manifest() tq.Manifest |
no test coverage detected