Skip to content

Commit

Permalink
feat(joint_teapot/app.py): allowing to submit in local existing repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ZJChe committed Jun 7, 2024
1 parent 9b3a8c4 commit 90defdb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions joint_teapot/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,19 @@ def JOJ3_scoreboard(
"", help="name of scoreboard file in the gitea repo"
),
) -> None:
# Does not allow to handle existing local repo
if os.path.exists(os.path.join(tea.pot.git.repos_dir, repo_name)):
from git import Repo

repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
repo: Repo = tea.pot.git.get_repo(repo_name)
if "grading" not in repo.remote().refs:
logger.error(
"This function does not allow to handle existing local repo, delete it first."
'"grading" branch not found in remote, create and push it to origin first.'
)
return
repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
if "grading" not in repo.branches:
logger.error('"grading" branch not found in local, create it first.')
return
repo.git.reset("--hard", "origin/grading")
joj3.generate_scoreboard(
scorefile_path, os.path.join(repo_path, scoreboard_file_name)
)
Expand Down

0 comments on commit 90defdb

Please sign in to comment.