MCPcopy
hub / github.com/cli/cli / cloneRun

Function cloneRun

pkg/cmd/label/clone.go:76–110  ·  view source on GitHub ↗
(opts *cloneOptions)

Source from the content-addressed store, hash-verified

74}
75
76func cloneRun(opts *cloneOptions) error {
77 httpClient, err := opts.HttpClient()
78 if err != nil {
79 return err
80 }
81
82 baseRepo, err := opts.BaseRepo()
83 if err != nil {
84 return err
85 }
86
87 opts.IO.StartProgressIndicator()
88 successCount, totalCount, err := cloneLabels(httpClient, baseRepo, opts)
89 opts.IO.StopProgressIndicator()
90 if err != nil {
91 return err
92 }
93
94 if opts.IO.IsStdoutTTY() {
95 cs := opts.IO.ColorScheme()
96 pluralize := func(num int) string {
97 return text.Pluralize(num, "label")
98 }
99
100 successCount := int(successCount)
101 switch {
102 case successCount == totalCount:
103 fmt.Fprintf(opts.IO.Out, "%s Cloned %s from %s to %s\n", cs.SuccessIcon(), pluralize(successCount), ghrepo.FullName(opts.SourceRepo), ghrepo.FullName(baseRepo))
104 default:
105 fmt.Fprintf(opts.IO.Out, "%s Cloned %s of %d from %s to %s\n", cs.WarningIcon(), pluralize(successCount), totalCount, ghrepo.FullName(opts.SourceRepo), ghrepo.FullName(baseRepo))
106 }
107 }
108
109 return nil
110}
111
112func cloneLabels(client *http.Client, destination ghrepo.Interface, opts *cloneOptions) (successCount uint32, totalCount int, err error) {
113 successCount = 0

Callers 2

newCmdCloneFunction · 0.70
TestCloneRunFunction · 0.70

Calls 10

PluralizeFunction · 0.92
FullNameFunction · 0.92
cloneLabelsFunction · 0.85
IsStdoutTTYMethod · 0.80
ColorSchemeMethod · 0.80
SuccessIconMethod · 0.80
WarningIconMethod · 0.80
BaseRepoMethod · 0.65
StopProgressIndicatorMethod · 0.65

Tested by 1

TestCloneRunFunction · 0.56