ShortRef strips the "refs/heads/" or "refs/tags/" prefix from a fully qualified ref, returning the short name. If the ref is not fully qualified it is returned as-is.
(ref string)
| 136 | // ShortRef strips the "refs/heads/" or "refs/tags/" prefix from a fully qualified ref, |
| 137 | // returning the short name. If the ref is not fully qualified it is returned as-is. |
| 138 | func ShortRef(ref string) string { |
| 139 | if after, ok := strings.CutPrefix(ref, "refs/heads/"); ok { |
| 140 | return after |
| 141 | } |
| 142 | if after, ok := strings.CutPrefix(ref, "refs/tags/"); ok { |
| 143 | return after |
| 144 | } |
| 145 | return ref |
| 146 | } |
| 147 | |
| 148 | type treeEntry struct { |
| 149 | Path string `json:"path"` |
no outgoing calls