fix(update): discard server-side file mode changes on update and update repo links
This commit is contained in:
@@ -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
|
||||
|
||||
4
cli.py
4
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"
|
||||
|
||||
6
hdg
6
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."
|
||||
|
||||
Reference in New Issue
Block a user