From f7f48559536d17041fde07523e21fb1cbd570ee7 Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Tue, 3 Sep 2024 23:17:13 +0930 Subject: [PATCH] refactor: adjust git file names --- backend/app/git/__init__.py | 13 ++++++------- backend/app/git/{ => auth}/authenticate.py | 0 .../app/git/branches/{branches.py => manager.py} | 0 .../git/operations/{operations.py => manager.py} | 0 backend/app/git/{clone_repo.py => repo/clone.py} | 2 +- backend/app/git/{unlink_repo.py => repo/unlink.py} | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) rename backend/app/git/{ => auth}/authenticate.py (100%) rename backend/app/git/branches/{branches.py => manager.py} (100%) rename backend/app/git/operations/{operations.py => manager.py} (100%) rename backend/app/git/{clone_repo.py => repo/clone.py} (98%) rename backend/app/git/{unlink_repo.py => repo/unlink.py} (97%) diff --git a/backend/app/git/__init__.py b/backend/app/git/__init__.py index 94282b9..233624e 100644 --- a/backend/app/git/__init__.py +++ b/backend/app/git/__init__.py @@ -1,11 +1,11 @@ from flask import Blueprint, request, jsonify from .status.status import get_git_status from .status.diff import get_diff -from .branches.branches import Branch_Manager -from .operations.operations import GitOperations -from .unlink_repo import unlink_repository -from .clone_repo import clone_repository -from .authenticate import validate_git_token +from .branches.manager import Branch_Manager +from .operations.manager import GitOperations +from .repo.unlink import unlink_repository +from .repo.clone import clone_repository +from .auth.authenticate import validate_git_token from ..settings_utils import save_settings import logging @@ -13,7 +13,6 @@ logger = logging.getLogger(__name__) bp = Blueprint('git', __name__, url_prefix='/git') -# Assume these are set up elsewhere, perhaps in a config file REPO_PATH = '/app/data/db' branch_manager = Branch_Manager(REPO_PATH) git_operations = GitOperations(REPO_PATH) @@ -189,7 +188,7 @@ def handle_stage_files(): return jsonify({'success': False, 'error': message}), 400 @bp.route('/unlink', methods=['POST']) -def unlink_repo(): +def unlink(): data = request.get_json() remove_files = data.get('removeFiles', False) success, message = unlink_repository(REPO_PATH, remove_files) diff --git a/backend/app/git/authenticate.py b/backend/app/git/auth/authenticate.py similarity index 100% rename from backend/app/git/authenticate.py rename to backend/app/git/auth/authenticate.py diff --git a/backend/app/git/branches/branches.py b/backend/app/git/branches/manager.py similarity index 100% rename from backend/app/git/branches/branches.py rename to backend/app/git/branches/manager.py diff --git a/backend/app/git/operations/operations.py b/backend/app/git/operations/manager.py similarity index 100% rename from backend/app/git/operations/operations.py rename to backend/app/git/operations/manager.py diff --git a/backend/app/git/clone_repo.py b/backend/app/git/repo/clone.py similarity index 98% rename from backend/app/git/clone_repo.py rename to backend/app/git/repo/clone.py index fb9922a..cfb5599 100644 --- a/backend/app/git/clone_repo.py +++ b/backend/app/git/repo/clone.py @@ -6,7 +6,7 @@ import logging import yaml from git.exc import GitCommandError import git -from .authenticate import validate_git_token +from ..auth.authenticate import validate_git_token logger = logging.getLogger(__name__) diff --git a/backend/app/git/unlink_repo.py b/backend/app/git/repo/unlink.py similarity index 97% rename from backend/app/git/unlink_repo.py rename to backend/app/git/repo/unlink.py index 72ebe37..10dc77f 100644 --- a/backend/app/git/unlink_repo.py +++ b/backend/app/git/repo/unlink.py @@ -4,7 +4,7 @@ from flask import Blueprint, jsonify, request import logging # Import settings utilities -from ..settings_utils import save_settings, load_settings +from ...settings_utils import save_settings, load_settings logger = logging.getLogger(__name__)