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