diff --git a/README.md b/README.md index d24d658..c02b6db 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,8 @@ hestia-django-gunicorn/ Clone the repository anywhere (e.g. `/opt` or your home directory) and run `hdg` once: ```bash -git clone https://github.com/amin-baranzehi/hestia-django-gunicorn.git -cd hestia-django-gunicorn +git clone git@git.amin.baranzehi.com:amin/hdg.git +cd hdg # Installs templates to HestiaCP and links 'hdg' globally sudo ./hdg install-templates diff --git a/cli.py b/cli.py index b4004bb..59dbe2d 100644 --- a/cli.py +++ b/cli.py @@ -265,6 +265,7 @@ def cmd_update(args: argparse.Namespace) -> int: git_dir = PROJECT_ROOT / ".git" if git_dir.exists(): info("Pulling latest updates from git...") + executor.run(f"git -C {PROJECT_ROOT} checkout -- .", check=False) rc, out, err = executor.run(f"git -C {PROJECT_ROOT} pull --ff-only", check=False) if rc == 0: success("Repository updated to latest commit.") @@ -273,7 +274,8 @@ def cmd_update(args: argparse.Namespace) -> int: if rc2 == 0: success("Repository updated.") else: - warn(f"Could not pull updates from git: {err or err2}") + executor.run(f"git -C {PROJECT_ROOT} reset --hard @{{u}}", check=False) + success("Repository synchronized with upstream.") # 2. Update templates in HestiaCP tpl_dir = PROJECT_ROOT / "templates" diff --git a/hdg b/hdg index 280bc0d..53f80d1 100755 --- a/hdg +++ b/hdg @@ -83,9 +83,13 @@ self_update() { if [ -d "${PROJECT_ROOT}/.git" ] && command -v git &>/dev/null; then info "Pulling latest changes from git repository..." + git -C "$PROJECT_ROOT" checkout -- . 2>/dev/null || true git -C "$PROJECT_ROOT" pull --ff-only 2>/dev/null || { warn "git pull --ff-only failed, trying standard pull..." - git -C "$PROJECT_ROOT" pull || warn "Could not pull git updates (check network or local changes)" + git -C "$PROJECT_ROOT" pull 2>/dev/null || { + warn "Pull conflict detected, resetting to upstream branch..." + git -C "$PROJECT_ROOT" reset --hard "@{u}" 2>/dev/null || warn "Could not pull git updates" + } } else info "Git repository not detected, skipping git pull."