ShowRefs resolves fully-qualified refs to commit hashes.
(ctx context.Context, refs []string)
| 241 | |
| 242 | // ShowRefs resolves fully-qualified refs to commit hashes. |
| 243 | func (c *Client) ShowRefs(ctx context.Context, refs []string) ([]Ref, error) { |
| 244 | args := append([]string{"show-ref", "--verify", "--"}, refs...) |
| 245 | cmd, err := c.Command(ctx, args...) |
| 246 | if err != nil { |
| 247 | return nil, err |
| 248 | } |
| 249 | // This functionality relies on parsing output from the git command despite |
| 250 | // an error status being returned from git. |
| 251 | out, err := cmd.Output() |
| 252 | var verified []Ref |
| 253 | for _, line := range outputLines(out) { |
| 254 | parts := strings.SplitN(line, " ", 2) |
| 255 | if len(parts) < 2 { |
| 256 | continue |
| 257 | } |
| 258 | verified = append(verified, Ref{ |
| 259 | Hash: parts[0], |
| 260 | Name: parts[1], |
| 261 | }) |
| 262 | } |
| 263 | return verified, err |
| 264 | } |
| 265 | |
| 266 | func (c *Client) Config(ctx context.Context, name string) (string, error) { |
| 267 | args := []string{"config", name} |