Use rev-list --all --objects --disk-usage to calculate repository usage
Add a Size() method for repo that calculates disk usage of objects. The way we currently calculate repository size is to use du(1), which is a quick and dirty way to get the total storage of a repository. However, this ends up varying depending on the how the objects are stored by Git, which is affected by repository maintenance strategies and can vary.
A more consistent way to calculate storage is to get a total of number of reachable objects with git rev-list --all --objects --disk-usage
This still can vary based on the state of the repository, whether or not it's packed. But, this will give us a more consistent value than using du(1).
part of: https://gitlab.com/gitlab-org/gitlab/-/issues/351415
Edited by John Cai