RepoManager#
- class mobu.services.repo.RepoManager(logger, *, testing=False)#
Bases:
object
A reference-counting caching repo cloner.
Only the first call to
clone
for a given repo url and ref will clone the repo. Subsequent calls will return the location and hash of the already-cloned repo.A call to
invalidate
will make it so that the next call toclone
will re-clone the repo to a different path.A call to
clone
also increases a reference counter for the url + ref + hash combo of the cloned repo. A call toinvalidate
for that combo decreases the counter.Invalidate
will only delete the files from the cloned repo if the reference count drops to 0.- Parameters:
logger (
BoundLogger
) – A loggertesting (
bool
, default:False
)
Methods Summary
clone
(url, ref, username)Clone a git repo or return cached info by url + ref.
close
()Delete all cloned repos and containing directory.
invalidate
(url, ref, repo_hash, username)Invalidate a git repo in the cache by url + ref.
Methods Documentation
- async clone(url, ref, username)#
Clone a git repo or return cached info by url + ref.
Increase the reference count for the url + ref + hash combo.
- Parameters:
- Return type:
- async invalidate(url, ref, repo_hash, username)#
Invalidate a git repo in the cache by url + ref.
Decrease the url + ref + hash reference count. If it drops to zero, delete the files from that clone.