feat: clean git lock file for joj3
This commit is contained in:
parent
78b97adec2
commit
ebf7e04282
|
@ -264,7 +264,9 @@ def joj3_scoreboard(
|
||||||
)
|
)
|
||||||
with FileLock(lock_file_path, timeout=settings.joj3_lock_file_timeout).acquire():
|
with FileLock(lock_file_path, timeout=settings.joj3_lock_file_timeout).acquire():
|
||||||
logger.info("file lock acquired")
|
logger.info("file lock acquired")
|
||||||
repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
|
repo_path = tea.pot.git.repo_clean_and_checkout(
|
||||||
|
repo_name, "grading", clean_git_lock=True
|
||||||
|
)
|
||||||
repo: Repo = tea.pot.git.get_repo(repo_name)
|
repo: Repo = tea.pot.git.get_repo(repo_name)
|
||||||
if "grading" not in repo.remote().refs:
|
if "grading" not in repo.remote().refs:
|
||||||
logger.error(
|
logger.error(
|
||||||
|
@ -344,7 +346,9 @@ def joj3_failed_table(
|
||||||
)
|
)
|
||||||
with FileLock(lock_file_path, timeout=settings.joj3_lock_file_timeout).acquire():
|
with FileLock(lock_file_path, timeout=settings.joj3_lock_file_timeout).acquire():
|
||||||
logger.info("file lock acquired")
|
logger.info("file lock acquired")
|
||||||
repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
|
repo_path = tea.pot.git.repo_clean_and_checkout(
|
||||||
|
repo_name, "grading", clean_git_lock=True
|
||||||
|
)
|
||||||
repo: Repo = tea.pot.git.get_repo(repo_name)
|
repo: Repo = tea.pot.git.get_repo(repo_name)
|
||||||
if "grading" not in repo.remote().refs:
|
if "grading" not in repo.remote().refs:
|
||||||
logger.error(
|
logger.error(
|
||||||
|
@ -555,7 +559,9 @@ def joj3_all(
|
||||||
retry_interval = 1
|
retry_interval = 1
|
||||||
git_push_ok = False
|
git_push_ok = False
|
||||||
while not git_push_ok:
|
while not git_push_ok:
|
||||||
repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
|
repo_path = tea.pot.git.repo_clean_and_checkout(
|
||||||
|
repo_name, "grading", clean_git_lock=True
|
||||||
|
)
|
||||||
repo: Repo = tea.pot.git.get_repo(repo_name)
|
repo: Repo = tea.pot.git.get_repo(repo_name)
|
||||||
if "grading" not in repo.remote().refs:
|
if "grading" not in repo.remote().refs:
|
||||||
logger.error(
|
logger.error(
|
||||||
|
|
|
@ -72,7 +72,11 @@ class Git:
|
||||||
return self.clone_repo(repo_name)
|
return self.clone_repo(repo_name)
|
||||||
|
|
||||||
def repo_clean_and_checkout(
|
def repo_clean_and_checkout(
|
||||||
self, repo_name: str, checkout_dest: str, auto_retry: bool = True
|
self,
|
||||||
|
repo_name: str,
|
||||||
|
checkout_dest: str,
|
||||||
|
auto_retry: bool = True,
|
||||||
|
clean_git_lock: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
repo_dir = os.path.join(self.repos_dir, repo_name)
|
repo_dir = os.path.join(self.repos_dir, repo_name)
|
||||||
repo = self.get_repo(repo_name)
|
repo = self.get_repo(repo_name)
|
||||||
|
@ -81,6 +85,10 @@ class Git:
|
||||||
retry_interval = 2
|
retry_interval = 2
|
||||||
while retry_interval and auto_retry:
|
while retry_interval and auto_retry:
|
||||||
try:
|
try:
|
||||||
|
if clean_git_lock and os.path.exists(
|
||||||
|
os.path.join(repo_dir, ".git/index.lock")
|
||||||
|
):
|
||||||
|
os.remove(os.path.join(repo_dir, ".git/index.lock"))
|
||||||
repo.git.fetch("--tags", "--all", "-f")
|
repo.git.fetch("--tags", "--all", "-f")
|
||||||
repo.git.reset("--hard", "origin/master")
|
repo.git.reset("--hard", "origin/master")
|
||||||
repo.git.clean("-d", "-f", "-x")
|
repo.git.clean("-d", "-f", "-x")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user