GetCommitHash try to get commit hash from `commitHashCache` first, if not exist then get it by calling `doGetCommitHash`.
(nameVersion string, native bool)
| 187 | // GetCommitHash try to get commit hash from `commitHashCache` first, |
| 188 | // if not exist then get it by calling `doGetCommitHash`. |
| 189 | func (p Port) GetCommitHash(nameVersion string, native bool) (string, error) { |
| 190 | key := nameVersion |
| 191 | if v, ok := commitHashCache.Load(key); ok { |
| 192 | r := v.(metaResult) |
| 193 | return r.meta, r.err |
| 194 | } |
| 195 | |
| 196 | // Don't cache ErrRepoNotExit — the repo may be cloned later in the same run. |
| 197 | result, err := p.doGetCommitHash(nameVersion, native) |
| 198 | if err == nil || !errors.Is(err, errors.ErrRepoNotExit) { |
| 199 | commitHashCache.Store(key, metaResult{meta: result, err: err}) |
| 200 | } |
| 201 | return result, err |
| 202 | } |
| 203 | |
| 204 | func (p Port) doGetCommitHash(nameVersion string, native bool) (string, error) { |
| 205 | var port = Port{DevDep: native} |
nothing calls this directly
no test coverage detected