(absRef, sha string)
| 79 | } |
| 80 | |
| 81 | func ParseRef(absRef, sha string) *Ref { |
| 82 | r := &Ref{Sha: sha} |
| 83 | if strings.HasPrefix(absRef, "refs/heads/") { |
| 84 | r.Name = absRef[11:] |
| 85 | r.Type = RefTypeLocalBranch |
| 86 | } else if strings.HasPrefix(absRef, "refs/tags/") { |
| 87 | r.Name = absRef[10:] |
| 88 | r.Type = RefTypeLocalTag |
| 89 | } else if strings.HasPrefix(absRef, "refs/remotes/") { |
| 90 | r.Name = absRef[13:] |
| 91 | r.Type = RefTypeRemoteBranch |
| 92 | } else { |
| 93 | r.Name = absRef |
| 94 | if absRef == "HEAD" { |
| 95 | r.Type = RefTypeHEAD |
| 96 | } else { |
| 97 | r.Type = RefTypeOther |
| 98 | } |
| 99 | } |
| 100 | return r |
| 101 | } |
| 102 | |
| 103 | // A git reference (branch, tag etc) |
| 104 | type Ref struct { |
no outgoing calls