Dst returns the destination for the given remote reference.
(n plumbing.ReferenceName)
| 115 | |
| 116 | // Dst returns the destination for the given remote reference. |
| 117 | func (s RefSpec) Dst(n plumbing.ReferenceName) plumbing.ReferenceName { |
| 118 | spec := string(s) |
| 119 | start := strings.Index(spec, refSpecSeparator) + 1 |
| 120 | dst := spec[start:] |
| 121 | src := s.Src() |
| 122 | |
| 123 | if !s.IsWildcard() { |
| 124 | return plumbing.ReferenceName(dst) |
| 125 | } |
| 126 | |
| 127 | name := n.String() |
| 128 | ws := strings.Index(src, refSpecWildcard) |
| 129 | wd := strings.Index(dst, refSpecWildcard) |
| 130 | match := name[ws : len(name)-(len(src)-(ws+1))] |
| 131 | |
| 132 | return plumbing.ReferenceName(dst[0:wd] + match + dst[wd+1:]) |
| 133 | } |
| 134 | |
| 135 | func (s RefSpec) Reverse() RefSpec { |
| 136 | spec := string(s) |