| 706 | } |
| 707 | |
| 708 | func (d *DotGit) SetRef(r, old *plumbing.Reference) error { |
| 709 | var content string |
| 710 | switch r.Type() { |
| 711 | case plumbing.SymbolicReference: |
| 712 | content = fmt.Sprintf("ref: %s\n", r.Target()) |
| 713 | case plumbing.HashReference: |
| 714 | content = fmt.Sprintln(r.Hash().String()) |
| 715 | } |
| 716 | |
| 717 | fileName := r.Name().String() |
| 718 | |
| 719 | return d.setRef(fileName, content, old) |
| 720 | } |
| 721 | |
| 722 | // Refs scans the git directory collecting references, which it returns. |
| 723 | // Symbolic references are resolved and included in the output. |