MCPcopy Create free account
hub / github.com/HashLoad/boss / UpdateCacheEmbedded

Function UpdateCacheEmbedded

core/gitWrapper/git_embedded.go:40–63  ·  view source on GitHub ↗
(dep models.Dependency)

Source from the content-addressed store, hash-verified

38}
39
40func UpdateCacheEmbedded(dep models.Dependency) *git.Repository {
41 storageCache := makeStorageCache(dep)
42 wtFs := makeWtFileSystem(dep)
43
44 repository, err := git.Open(storageCache, wtFs)
45 if err != nil {
46 msg.Warn("Error to open cache of %s: %s", dep.Repository, err)
47 repository = refreshCopy(dep)
48 } else {
49 worktree, _ := repository.Worktree()
50 _ = worktree.Reset(&git.ResetOptions{
51 Mode: git.HardReset,
52 })
53 }
54
55 err = repository.Fetch(&git.FetchOptions{
56 Force: true,
57 Auth: env.GlobalConfiguration.GetAuth(dep.GetURLPrefix())})
58 if err != nil && err.Error() != "already up-to-date" {
59 msg.Debug("Error to fetch repository of %s: %s", dep.Repository, err)
60 }
61 initSubmodules(dep, repository)
62 return repository
63}
64
65func refreshCopy(dep models.Dependency) *git.Repository {
66 dir := filepath.Join(env.GetCacheDir(), dep.GetHashName())

Callers 1

UpdateCacheFunction · 0.85

Calls 8

WarnFunction · 0.92
DebugFunction · 0.92
makeStorageCacheFunction · 0.85
makeWtFileSystemFunction · 0.85
refreshCopyFunction · 0.85
initSubmodulesFunction · 0.85
GetAuthMethod · 0.80
GetURLPrefixMethod · 0.80

Tested by

no test coverage detected