Skip to content

move git backend behind an interface #25752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
6543 opened this issue Jul 7, 2023 · 8 comments
Open

move git backend behind an interface #25752

6543 opened this issue Jul 7, 2023 · 8 comments
Labels
type/refactoring Existing code has been cleaned up. There should be no new functionality. type/summary This issue aggregates a bunch of other issues

Comments

@6543
Copy link
Member

6543 commented Jul 7, 2023

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

  1. Module Restructuring: Move the Git module (e.g., module/git) to a submodule within module/git, and initiate the construction of the fundamental interface.

  2. Interface Definition: Define the interface for Git operations (e.g., Git open) incrementally, piece by piece, at module/git.

  3. Backend Segmentation: Segment the implementation of GoGit and NoGoGit, transitioning from using compile flags to run time settings.

  4. 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.

  5. 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.

@6543 6543 added type/refactoring Existing code has been cleaned up. There should be no new functionality. type/summary This issue aggregates a bunch of other issues labels Jul 7, 2023
@6543
Copy link
Member Author

6543 commented Jul 7, 2023

this also might enable to use https://gitlab.com/gitlab-org/gitaly for us ... or split gitea int microservices ... (as one option)

@techknowlogick
Copy link
Member

closing as dupe of #25070

@techknowlogick techknowlogick added issue/duplicate The issue has already been reported. and removed type/refactoring Existing code has been cleaned up. There should be no new functionality. type/summary This issue aggregates a bunch of other issues labels Jul 7, 2023
@6543
Copy link
Member Author

6543 commented Aug 10, 2023

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

@6543 6543 reopened this Aug 10, 2023
@6543 6543 added pr/wip This PR is not ready for review and removed issue/duplicate The issue has already been reported. labels Aug 10, 2023
@6543

This comment was marked as outdated.

@6543 6543 added type/refactoring Existing code has been cleaned up. There should be no new functionality. type/summary This issue aggregates a bunch of other issues and removed pr/wip This PR is not ready for review labels Aug 10, 2023
@lunny
Copy link
Member

lunny commented Aug 11, 2023

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.

@6543
Copy link
Member Author

6543 commented Aug 11, 2023

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 #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

@wxiaoguang
Copy link
Contributor

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.

@6543
Copy link
Member Author

6543 commented Aug 18, 2023

not a bad idea too :)

I'll start with a smal pull and see if we can take it from there :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/refactoring Existing code has been cleaned up. There should be no new functionality. type/summary This issue aggregates a bunch of other issues
Projects
None yet
Development

No branches or pull requests

4 participants