Open 6543 opened 1 year ago
this also might enable to use https://gitlab.com/gitlab-org/gitaly for us ... or split gitea int microservices ... (as one option)
closing as dupe of https://github.com/go-gitea/gitea/issues/25070
Readun all the related issues&comments this is no dublicate ... mentiined issue is about storage of git data to be more portable ... the other is about our git functionalitys to move them behind an interface
Wip because of revormulate it
I don't think we need an abstract layer for all the git operations, we could just have one for git command. The first important thing is #25071, we use reporootpath everywhere which will prevent the abstract layer.
The problem with the git.Command is, that it allows arbitrary functionality to git ... yes we can do cover it as interface ... and I would do so first ... but it makes a hard requirement for the git binary and that that related git backend implementation. So in the long run I want to have it used only within the git modules specific implementation.
I agree that https://github.com/go-gitea/gitea/pull/25071 is higher in priority. This is about a long term goal, I want to refactor for the next versions ongoing (similar to how we migrated the http router) @lunny
PS: we already only use the git.Command in our code and not provide any external interaction (witch would be bad security wise) ... so it's just about moving that specific functions into the same package
IMO step 1 (Module Restructuring) is not necessary at the moment, while step 2 (Interface Definition) should be done first and needs more details.
The reason IMO is: Module Restructuring
could be done at any time, even without Module Restructuring, the new package could be named as modules/gitapi
or some funny name modules/gitter
. After the new package works well, then "modules/git" could be moved/renamed easily and safely.
not a bad idea too :)
I'll start with a smal pull and see if we can take it from there :D
The Issue
The current issue involves the handling of interactions with bare Git repositories. These interactions are currently integrated throughout the entire codebase.
The challenge revolves around unifying interactions with bare Git repositories while accommodating various backends and storage locations (for addressing storage locations, refer to Issue #25070).
The main objective is to create a central interface that consolidates actions related to Git, allowing for their distribution across different services. The aim is not an immediate replacement of the current implementation, but rather to enable such a transition in the future if necessary.
This proposed solution would also lay the foundation for potentially separating the handling of git-bare-repositories into its own microservice at a later point.
This approach brings several benefits, including the ability for independent development and maintenance of various Git implementations, improved security through Separation of Concerns, and overall enhanced maintainability.
Furthermore, this approach could make Gitea more scalable in conjunction with Issue #25070, enabling the possibility of utilizing different microservices for different repositories, potentially divided by patterns or settings like the starting letters of repositories.
Proposed Solution
The proposed solution involves a phased implementation approach:
Initial Streamlining: The first step is to create a more concise implementation. This includes relocating the specific functions currently present in the
modules/git
package to a lower package level.Interface Abstraction & Encapsulation: Following this, a fundamental interface will be established within the
modules/git
package at a higher package level. This interface will abstract essential functionalities, providing a clear structure for interaction.Roadmap to Implementation
Module Restructuring: Move the Git module (e.g.,
module/git
) to a submodule withinmodule/git
, and initiate the construction of the fundamental interface.Interface Definition: Define the interface for Git operations (e.g., Git open) incrementally, piece by piece, at
module/git
.Backend Segmentation: Segment the implementation of GoGit and NoGoGit, transitioning from using compile flags to run time settings.
Completing the Interface: Finalize the comprehensive interface and align it with the abstraction of Git storage sources (Issue #25070). This enables the assignment of distinct storage areas to various microservices based on repository names, enhancing scalability.
Integration Consideration: Evaluate the integration of libgit2 bindings as another backend behind a compile flag like sqlite support
tldr: This proposal aims to streamline our Git-Interaction in Gitea, leading to improved maintainability, flexibility, security and overall performance.