| 1 | package tinygit |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "os" |
| 6 | ) |
| 7 | |
| 8 | // Native refs can include receive-pack staging work. The signed authority |
| 9 | // file identifies which exact ref/object pairs have actually been published. |
| 10 | func (g *GitRelay) publishedNativeRefs(r Repository) (map[string]string, error) { |
| 11 | published, err := readRefsFile(g.statePath(r)) |
| 12 | if errors.Is(err, os.ErrNotExist) { |
| 13 | return map[string]string{}, nil |
| 14 | } |
| 15 | if err != nil { |
| 16 | return nil, err |
| 17 | } |
| 18 | native, err := g.nativeRefs(r) |
| 19 | if err != nil { |
| 20 | return nil, err |
| 21 | } |
| 22 | for name, oid := range published { |
| 23 | if native[name] != oid || internalRef(name) { |
| 24 | delete(published, name) |
| 25 | } |
| 26 | } |
| 27 | return published, nil |
| 28 | } |