ParseMapping parses a CLI --map value into a ref mapping.
(raw string)
| 98 | |
| 99 | // ParseMapping parses a CLI --map value into a ref mapping. |
| 100 | func 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. |
no outgoing calls