Open lunny opened 7 months ago
Reduce fork repositories size
That will be a massive benefit for big hosters with many forks per repo and this is also how GitHub works under the hood. A repo and all of its forks use a shared git repo on the server, so if a repo has 1000 forks, you are only storing their changed branches.
Care needs to taken to prevent cross-repo influences. GitHub also had a number of issues related to this in the past (this comes to mind).
Purpose
Why we need an abstract layer for managed repositories? I think there are some benefit for that.
Concepts
I ever sent some PRs to want to introduce a layer in the
module/git
but I found it's not the right direction. That packagemodules/git
should be a basis package which will always focus on handling disk operations. Whatever the repository is the managed one, the wiki one, the temporary one or the hide one. So I think some concepts need to be introduced to clarify.modules/git
: This package should be a low level package which can handle any disk git repositories. For managed git repositories, a new package should be introduced.modules/gitrepo
: This is the new package introduced as an abstract layer to handle managed git repositories. It may include different storage strategy but the interface to other package is almost the same as before to hide the implementation details. This package will depend onmodules/git
and should not depend on anymodels
packages. It can be dependent by othermodules
,services
layer packages.Refactoring
To address the purpose, we need do some refactorings.
setting.RepoRootPath
into themodules/gitrepo
package. Any other non-test packages should not use it directly. There could be some method provided by that package likeGitStorageInfo
to return the storage methods and storage path but that should only be used as information displayed on UI.modules/gitrepo
but notmodules/git
and all the functions inmodules/gitrepo
should hide the absoluteRepoPath
even the relative storage path but useID
as directory name. Just use some interface likeRunGitCmd
should be in the new package. And it can become a proxy method to invoke different implementation.Mocking
To make the abstract work, we need a mocking git storage server which can reuse the current repository root path but all requests are come from the HTTP operations. So there will be two implemenations for the basic operations. i.e.
For mock http storage service
Related PRs
28937
28940
28966