registerResolved records a resolved module for a commit id (the canonical git sha) under commitMu. commitMap[sha]=ref lets future Downloads of the same sha hit directly. infoCache is populated with a digest-less entry — ServeDownload's miss-branch recomputes files+digest on first use, so the digest
(sha, owner, module string)
| 872 | // pre-warm would clobber a computed digest with nil and the next cache-hit |
| 873 | // Download would serve a zero digest. |
| 874 | func (h *commitServiceHandler) registerResolved(sha, owner, module string) { |
| 875 | key := owner + "/" + module |
| 876 | // The buf client now expects a 32-char dashless UUID; the SHA is only |
| 877 | // useful as a key for talking to upstream git. Register BOTH so the |
| 878 | // prewarm path makes the UUID the buf client will send hit commitMap |
| 879 | // directly on the first Download, and the SHA alias preserves a |
| 880 | // working lookup for any caller (probe, future debug tool) that |
| 881 | // happens to send a raw sha. |
| 882 | uuid := commitUUID(sha) |
| 883 | h.commitMu.Lock() |
| 884 | h.commitMap[uuid] = moduleRef{owner: owner, module: module} |
| 885 | if sha != "" && sha != uuid { |
| 886 | h.commitMap[sha] = moduleRef{owner: owner, module: module} |
| 887 | } |
| 888 | if existing, ok := h.infoCache[key]; ok { |
| 889 | existing.commitID = uuid |
| 890 | existing.commit = sha |
| 891 | existing.ownerID = owner |
| 892 | existing.moduleID = key |
| 893 | h.infoCache[key] = existing |
| 894 | } else { |
| 895 | h.infoCache[key] = commitInfoCache{ |
| 896 | commitID: uuid, |
| 897 | commit: sha, |
| 898 | ownerID: owner, |
| 899 | moduleID: key, |
| 900 | } |
| 901 | } |
| 902 | h.commitMu.Unlock() |
| 903 | } |
| 904 | |
| 905 | // prewarmHeads resolves the current HEAD commit of every configured module |
| 906 | // and registers it, so that a client sending a cached current-HEAD sha hits |
no test coverage detected