roundabout,
created on Saturday, 27 April 2024, 17:09:29 (1714237769),
received on Wednesday, 31 July 2024, 06:54:47 (1722408887)
Author identity: vlad <vlad.muntoiu@gmail.com>
f446a6c2e8534d0740b57bac079e2e28c0fa4b72
celery_tasks.py
@@ -3,6 +3,7 @@ import time
import os import config import email_send import shutilfrom celery import shared_task from app import db from smtplib import SMTP
@@ -90,12 +91,17 @@ def merge_heads(head_route, head_branch, base_route, base_branch, simulate=True)
def copy_site(route): from models import Repo # Create the site directory if it doesn't exist. if not os.path.isdir(os.path.join(config.SITE_PATH, route.lstrip("/"))):os.makedirs(os.path.join(config.SITE_PATH, route.lstrip("/")))if not os.path.isdir(os.path.join(config.SITE_PATH, route.rpartition("/")[0].lstrip("/"))): # create an user directory os.makedirs(os.path.join(config.SITE_PATH, route.rpartition("/")[0].lstrip("/")))repo = db.session.get(Repo, route) server_repo_location = os.path.join(config.REPOS_PATH, route.lstrip("/")) site_location = os.path.join(config.SITE_PATH, route.lstrip("/")) user_location = os.path.join(config.SITE_PATH, route.rpartition("/")[0].lstrip("/"))# Get the branch to be used for the site; if it somehow doesn't exist, use the default branch. branch = repo.site_branch or repo.default_branch # Make a shallow clone of the repo; this prevents getting the full git database when it's not needed. common.git_command(site_location, b"", "clone", "--depth=1", f"--branch={branch}", os.path.join(os.getcwd(), server_repo_location))if os.path.isdir(site_location): # Delete the old site. shutil.rmtree(site_location) common.git_command(user_location, b"", "clone", "--depth=1", f"--branch={branch}", os.path.join(os.getcwd(), server_repo_location))