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

Function ParseMapping

internal/validation/validation.go:100–111  ·  view source on GitHub ↗

ParseMapping parses a CLI --map value into a ref mapping.

(raw string)

Source from the content-addressed store, hash-verified

98
99// ParseMapping parses a CLI --map value into a ref mapping.
100func ParseMapping(raw string) (RefMapping, error) {
101 parts := strings.SplitN(raw, ":", 2)
102 if len(parts) != 2 {
103 return RefMapping{}, fmt.Errorf("invalid --map %q, expected src:dst", raw)
104 }
105 source := strings.TrimSpace(parts[0])
106 target := strings.TrimSpace(parts[1])
107 if source == "" || target == "" {
108 return RefMapping{}, fmt.Errorf("invalid --map %q, expected src:dst", raw)
109 }
110 return RefMapping{Source: source, Target: target}, nil
111}
112
113// ParseHaveRef normalizes a have-ref CLI value. Short names are treated as
114// branch names for compatibility with other CLI ref selectors.

Callers 4

newSyncLikeCmdFunction · 0.92
newBootstrapCmdFunction · 0.92
runFunction · 0.92
TestParseMappingFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseMappingFunction · 0.68