MCPcopy Create free account
hub / github.com/entireio/git-sync / newBootstrapCmd

Function newBootstrapCmd

cmd/git-sync/bootstrap.go:13–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11)
12
13func newBootstrapCmd() *cobra.Command {
14 var (
15 mappings []string
16 jsonOutput bool
17 sourceAuth gitsync.EndpointAuth
18 targetAuth gitsync.EndpointAuth
19 branches string
20 protocolVal = newProtocolFlag()
21 req = unstable.BootstrapRequest{}
22 )
23
24 cmd := &cobra.Command{
25 Use: "bootstrap [flags] <source-url> <target-url>",
26 Short: "Seed an empty target by streaming the source pack",
27 Args: cobra.MaximumNArgs(2),
28 SilenceErrors: true,
29 SilenceUsage: true,
30 RunE: func(cmd *cobra.Command, args []string) error {
31 req.Protocol = gitsync.ProtocolMode(protocolVal)
32
33 if req.Source.URL == "" && len(args) > 0 {
34 req.Source.URL = args[0]
35 }
36 if req.Target.URL == "" && len(args) > 1 {
37 req.Target.URL = args[1]
38 }
39
40 if branches != "" {
41 req.Scope.Branches = splitCSV(branches)
42 }
43 for _, raw := range mappings {
44 mapping, err := validation.ParseMapping(raw)
45 if err != nil {
46 return fmt.Errorf("parse mapping %q: %w", raw, err)
47 }
48 req.Scope.Mappings = append(req.Scope.Mappings, gitsync.RefMapping{
49 Source: mapping.Source,
50 Target: mapping.Target,
51 })
52 }
53
54 if req.Source.URL == "" || req.Target.URL == "" {
55 return errors.New("bootstrap requires source and target repository URLs")
56 }
57
58 result, err := unstable.New(unstable.Options{
59 Auth: gitsync.StaticAuthProvider{Source: sourceAuth, Target: targetAuth},
60 }).Bootstrap(cmd.Context(), req)
61 if err != nil {
62 return fmt.Errorf("bootstrap: %w", err)
63 }
64 printOutput(jsonOutput, result)
65 return nil
66 },
67 }
68
69 addSourceEndpoint(cmd, &req.Source)
70 addTargetEndpoint(cmd, &req.Target)

Callers 1

newRootCmdFunction · 0.85

Calls 13

ParseMappingFunction · 0.92
NewFunction · 0.92
newProtocolFlagFunction · 0.85
printOutputFunction · 0.85
addSourceEndpointFunction · 0.85
addTargetEndpointFunction · 0.85
addSourceAuthFunction · 0.85
addTargetAuthFunction · 0.85
allRefsFlagFunction · 0.85
excludeRefPrefixFlagFunction · 0.85
addProtocolFlagFunction · 0.85
BootstrapMethod · 0.80

Tested by

no test coverage detected