mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-26 01:03:35 +05:00
refactor: replace RepositoryManager by simple util functions
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -25,13 +25,13 @@ from components.webui_client.client_utils import (
|
||||
)
|
||||
|
||||
from core.instance_manager.instance_manager import InstanceManager
|
||||
from core.repo_manager.repo_manager import RepoManager
|
||||
from utils.common import backup_printer_config_dir
|
||||
from utils.filesystem_utils import (
|
||||
create_symlink,
|
||||
add_config_section,
|
||||
add_config_section_at_top,
|
||||
)
|
||||
from utils.git_utils import git_clone_wrapper, git_pull_wrapper
|
||||
from utils.input_utils import get_confirm
|
||||
from utils.logger import Logger
|
||||
|
||||
@@ -86,11 +86,9 @@ def install_client_config(client_data: BaseWebClient) -> None:
|
||||
def download_client_config(client_config: BaseWebClientConfig) -> None:
|
||||
try:
|
||||
Logger.print_status(f"Downloading {client_config.display_name} ...")
|
||||
rm = RepoManager(
|
||||
client_config.repo_url,
|
||||
target_dir=str(client_config.config_dir),
|
||||
)
|
||||
rm.clone_repo()
|
||||
repo = client_config.repo_url
|
||||
target_dir = client_config.config_dir
|
||||
git_clone_wrapper(repo, None, target_dir)
|
||||
except Exception:
|
||||
Logger.print_error(f"Downloading {client_config.display_name} failed!")
|
||||
raise
|
||||
@@ -111,12 +109,7 @@ def update_client_config(client: BaseWebClient) -> None:
|
||||
if settings.get("kiauh", "backup_before_update"):
|
||||
backup_client_config_data(client)
|
||||
|
||||
repo_manager = RepoManager(
|
||||
repo=client_config.repo_url,
|
||||
branch="master",
|
||||
target_dir=str(client_config.config_dir),
|
||||
)
|
||||
repo_manager.pull_repo()
|
||||
git_pull_wrapper(client_config.repo_url, client_config.config_dir)
|
||||
|
||||
Logger.print_ok(f"Successfully updated {client_config.display_name}.")
|
||||
Logger.print_info("Restart Klipper to reload the configuration!")
|
||||
|
||||
@@ -21,12 +21,17 @@ from components.webui_client.base_data import (
|
||||
)
|
||||
from components.webui_client.mainsail_data import MainsailData
|
||||
from core.backup_manager.backup_manager import BackupManager
|
||||
from core.repo_manager.repo_manager import RepoManager
|
||||
from core.settings.kiauh_settings import KiauhSettings
|
||||
from utils import NGINX_SITES_AVAILABLE, NGINX_CONFD
|
||||
from utils.common import get_install_status_webui
|
||||
from utils.constants import COLOR_CYAN, RESET_FORMAT, COLOR_YELLOW
|
||||
from utils.git_utils import get_latest_tag, get_latest_unstable_tag
|
||||
from utils.git_utils import (
|
||||
get_latest_tag,
|
||||
get_latest_unstable_tag,
|
||||
get_repo_name,
|
||||
get_local_commit,
|
||||
get_remote_commit,
|
||||
)
|
||||
from utils.logger import Logger
|
||||
|
||||
|
||||
@@ -48,9 +53,9 @@ def get_client_config_status(
|
||||
client_config = client.client_config.config_dir
|
||||
|
||||
return {
|
||||
"repo": RepoManager.get_repo_name(client_config),
|
||||
"local": RepoManager.get_local_commit(client_config),
|
||||
"remote": RepoManager.get_remote_commit(client_config),
|
||||
"repo": get_repo_name(client_config),
|
||||
"local": get_local_commit(client_config),
|
||||
"remote": get_remote_commit(client_config),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user