MCPcopy Create free account
hub / github.com/cli/cli / localInit

Function localInit

pkg/cmd/repo/create/create.go:804–829  ·  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

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