MCPcopy
hub / github.com/cli/cli / localInit

Function localInit

pkg/cmd/repo/create/create.go:805–830  ·  view source on GitHub ↗

clone the checkout branch to specified path

(gitClient *git.Client, remoteURL, path string)

Source from the content-addressed store, hash-verified

803
804// clone the checkout branch to specified path
805func localInit(gitClient *git.Client, remoteURL, path string) error {
806 ctx := context.Background()
807 gitInit, err := gitClient.Command(ctx, "init", path)
808 if err != nil {
809 return err
810 }
811 _, err = gitInit.Output()
812 if err != nil {
813 return err
814 }
815
816 // Copy the client so we do not modify the original client's RepoDir.
817 gc := gitClient.Copy()
818 gc.RepoDir = path
819
820 gitRemoteAdd, err := gc.Command(ctx, "remote", "add", "origin", remoteURL)
821 if err != nil {
822 return err
823 }
824 _, err = gitRemoteAdd.Output()
825 if err != nil {
826 return err
827 }
828
829 return nil
830}
831
832func interactiveRepoTemplate(client *http.Client, hostname, owner string, prompter iprompter) (*api.Repository, error) {
833 templateRepos, err := listTemplateRepositories(client, hostname, owner)

Callers 1

createFromScratchFunction · 0.85

Calls 3

CommandMethod · 0.80
OutputMethod · 0.65
CopyMethod · 0.45

Tested by

no test coverage detected