SetReference honors the storer.ReferenceStorer interface.
(ref, old *plumbing.Reference)
| 36 | |
| 37 | // SetReference honors the storer.ReferenceStorer interface. |
| 38 | func (r *ReferenceStorage) CheckAndSetReference(ref, old *plumbing.Reference) error { |
| 39 | if old == nil { |
| 40 | return r.SetReference(ref) |
| 41 | } |
| 42 | |
| 43 | tmp, err := r.temporal.Reference(old.Name()) |
| 44 | if err == plumbing.ErrReferenceNotFound { |
| 45 | tmp, err = r.ReferenceStorer.Reference(old.Name()) |
| 46 | } |
| 47 | |
| 48 | if err != nil { |
| 49 | return err |
| 50 | } |
| 51 | |
| 52 | if tmp.Hash() != old.Hash() { |
| 53 | return storage.ErrReferenceHasChanged |
| 54 | } |
| 55 | |
| 56 | return r.SetReference(ref) |
| 57 | } |
| 58 | |
| 59 | // Reference honors the storer.ReferenceStorer interface. |
| 60 | func (r ReferenceStorage) Reference(n plumbing.ReferenceName) (*plumbing.Reference, error) { |