feat: set reset target

This commit is contained in:
张泊明518370910136 2024-11-19 07:15:30 -05:00
parent 3550042c8e
commit 16028d8195
GPG Key ID: CA088E6D9284F870
2 changed files with 7 additions and 2 deletions

View File

@ -568,7 +568,10 @@ def joj3_all(
git_push_ok = False
while not git_push_ok:
repo_path = tea.pot.git.repo_clean_and_checkout(
repo_name, "grading", clean_git_lock=True
repo_name,
"grading",
clean_git_lock=True,
reset_target="origin/grading",
)
repo: Repo = tea.pot.git.get_repo(repo_name)
if "grading" not in repo.remote().refs:

View File

@ -75,8 +75,10 @@ class Git:
self,
repo_name: str,
checkout_dest: str,
*,
auto_retry: bool = True,
clean_git_lock: bool = False,
reset_target: str = "origin/master",
) -> str:
repo_dir = os.path.join(self.repos_dir, repo_name)
repo = self.get_repo(repo_name)
@ -92,7 +94,7 @@ class Git:
if os.path.exists(lock_path):
os.remove(lock_path)
repo.git.fetch("--tags", "--all", "-f")
repo.git.reset("--hard", "origin/master")
repo.git.reset("--hard", reset_target)
repo.git.clean("-d", "-f", "-x")
repo.git.checkout(checkout_dest)
retry_interval = 0