pkgCacheStoreSkipReason returns the reason the artifact pkgcache upload should be skipped after a source build. Empty string means upload is OK.
()
| 205 | // pkgCacheStoreSkipReason returns the reason the artifact pkgcache upload |
| 206 | // should be skipped after a source build. Empty string means upload is OK. |
| 207 | func (p *Port) pkgCacheStoreSkipReason() (string, error) { |
| 208 | if p.ctx.Offline() { |
| 209 | return "offline mode", nil |
| 210 | } |
| 211 | |
| 212 | // Check if source modified. |
| 213 | if fileio.PathExists(p.MatchedConfig.PortConfig.RepoDir) { |
| 214 | modified, err := git.IsModified(p.MatchedConfig.PortConfig.RepoDir) |
| 215 | if err != nil { |
| 216 | return "", err |
| 217 | } |
| 218 | p.sourceModified = modified |
| 219 | if p.sourceModified { |
| 220 | return "source repo is modified", nil |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | // Only repos that match the configured source ref can store package cache. |
| 225 | if strings.HasSuffix(p.MatchedConfig.PortConfig.Url, ".git") { |
| 226 | repoRef := expr.If(p.Package.Checksum != "", p.Package.Checksum, p.Package.Ref) |
| 227 | mismatchDetails, err := git.CheckIfRefMatches(p.ctx, p.NameVersion(), p.MatchedConfig.PortConfig.RepoDir, repoRef) |
| 228 | if err != nil { |
| 229 | return "", fmt.Errorf("failed to check if ref matches for %s -> %w", p.NameVersion(), err) |
| 230 | } |
| 231 | if mismatchDetails != "" { |
| 232 | return mismatchDetails, nil |
| 233 | } |
| 234 | } |
| 235 | return "", nil |
| 236 | } |
| 237 | |
| 238 | func (p Port) Clone() error { |
| 239 | // Skip if this port was already cloned in the current cloneAllRepos run. |
no test coverage detected