From c3932538e1f97d8e014aa9c56c5cd7c4f6fffa3e Mon Sep 17 00:00:00 2001 From: Will Miao Date: Fri, 7 Nov 2025 08:17:20 +0800 Subject: [PATCH] feat: add git reset and clean before nightly and release updates, fixes #646 Add hard reset and clean operations to ensure a clean working directory before switching branches or checking out release tags. This prevents local changes from interfering with the update process and ensures consistent behavior across both nightly and release update paths. --- py/routes/update_routes.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/py/routes/update_routes.py b/py/routes/update_routes.py index 9be3cf1b..aa636588 100644 --- a/py/routes/update_routes.py +++ b/py/routes/update_routes.py @@ -344,6 +344,11 @@ class UpdateRoutes: origin.fetch() if nightly: + # Reset to discard any local changes + repo.git.reset('--hard') + # Clean untracked files + repo.git.clean('-fd') + # Switch to main branch and pull latest main_branch = 'main' if main_branch not in [branch.name for branch in repo.branches]: @@ -357,6 +362,11 @@ class UpdateRoutes: new_version = f"main-{repo.head.commit.hexsha[:7]}" else: + # Reset to discard any local changes + repo.git.reset('--hard') + # Clean untracked files + repo.git.clean('-fd') + # Get latest release tag tags = sorted(repo.tags, key=lambda t: t.commit.committed_datetime, reverse=True) if not tags: