Fix: Remove lock files before git reset

This commit is contained in:
LmeSzinc 2023-10-23 22:24:58 +08:00
parent dcb0c5eca7
commit 0bbfea6bd0

View File

@ -208,6 +208,15 @@ class GitOverCdnClient:
"""
git reset --hard <commit>
"""
# Remove git lock
for lock_file in [
'./.git/index.lock',
'./.git/HEAD.lock',
'./.git/refs/heads/master.lock',
]:
if os.path.exists(lock_file):
self.logger.info(f'Lock file {lock_file} exists, removing')
os.remove(lock_file)
if keep_changes:
self.git_command('stash')
self.git_command('reset', '--hard', f'{self.source}/{self.branch}')