(cmd *cobra.Command, args []string)
| 22 | ) |
| 23 | |
| 24 | func cloneCommand(cmd *cobra.Command, args []string) { |
| 25 | requireGitVersion() |
| 26 | |
| 27 | if git.IsGitVersionAtLeast("2.15.0") { |
| 28 | // TRANSLATORS: Individual lines should not exceed 80 |
| 29 | // characters, and any additional lines in the first message |
| 30 | // should be indented to align with the first line's text |
| 31 | // following the warning prefix and punctuation. |
| 32 | msg := fmt.Sprintf("%s\n\n%s", |
| 33 | tr.Tr.Get("WARNING: `git lfs clone` is deprecated and will not be updated\n with new flags from `git clone`"), |
| 34 | tr.Tr.Get("`git clone` has been updated in upstream Git to have comparable\nspeeds to `git lfs clone`.")) |
| 35 | |
| 36 | fmt.Fprintln(os.Stderr, msg) |
| 37 | } |
| 38 | |
| 39 | // We pass all args to git clone |
| 40 | err := git.CloneWithoutFilters(cloneFlags, args) |
| 41 | if err != nil { |
| 42 | Exit("%s\n%v", tr.Tr.Get("Error(s) during clone:"), err) |
| 43 | } |
| 44 | |
| 45 | // now execute pull (need to be inside dir) |
| 46 | cwd, err := tools.Getwd() |
| 47 | if err != nil { |
| 48 | Exit(tr.Tr.Get("Unable to derive current working dir: %v", err)) |
| 49 | } |
| 50 | |
| 51 | // Either the last argument was a relative or local dir, or we have to |
| 52 | // derive it from the clone URL |
| 53 | clonedir, err := filepath.Abs(args[len(args)-1]) |
| 54 | if err != nil || !tools.DirExists(clonedir) { |
| 55 | // Derive from clone URL instead |
| 56 | base := path.Base(args[len(args)-1]) |
| 57 | if strings.HasSuffix(base, ".git") { |
| 58 | base = base[:len(base)-4] |
| 59 | } |
| 60 | clonedir, _ = filepath.Abs(base) |
| 61 | if !tools.DirExists(clonedir) { |
| 62 | Exit(tr.Tr.Get("Unable to find clone dir at %q", clonedir)) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | err = os.Chdir(clonedir) |
| 67 | if err != nil { |
| 68 | Exit(tr.Tr.Get("Unable to change directory to clone dir %q: %v", clonedir, err)) |
| 69 | } |
| 70 | |
| 71 | // Make sure we pop back to dir we started in at the end |
| 72 | defer os.Chdir(cwd) |
| 73 | |
| 74 | setupRepository() |
| 75 | |
| 76 | // Support --origin option to clone |
| 77 | if len(cloneFlags.Origin) > 0 { |
| 78 | cfg.SetRemote(cloneFlags.Origin) |
| 79 | } |
| 80 | |
| 81 | if ref, err := git.CurrentRef(); err == nil { |
nothing calls this directly
no test coverage detected