|
|
|
|
@ -98,10 +98,11 @@ class GitPusherRequestHandler(BaseHTTPRequestHandler):
|
|
|
|
|
logger.info(f"Created temp directory: {temp_dir}")
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
# Préparer l'URL Git
|
|
|
|
|
# Préparer l'URL Git avec le token
|
|
|
|
|
git_url_with_token = self.prepare_git_url(git_url, git_token)
|
|
|
|
|
|
|
|
|
|
# Cloner
|
|
|
|
|
logger.info(f"Git URL prepared (token inserted)")
|
|
|
|
|
logger.debug(f"Git URL with token: {git_url_with_token}")
|
|
|
|
|
logger.info("Cloning repository...")
|
|
|
|
|
self.clone_repository(temp_dir, git_url_with_token, git_branch)
|
|
|
|
|
|
|
|
|
|
@ -122,6 +123,11 @@ class GitPusherRequestHandler(BaseHTTPRequestHandler):
|
|
|
|
|
|
|
|
|
|
if os.path.exists(app_path):
|
|
|
|
|
logger.info(f"Copying app {app_name} from {app_path}")
|
|
|
|
|
# Supprimer le dossier s'il existe déjà
|
|
|
|
|
if os.path.exists(dest_path):
|
|
|
|
|
logger.info(f"Removing existing app directory: {dest_path}")
|
|
|
|
|
shutil.rmtree(dest_path)
|
|
|
|
|
# Copier le dossier
|
|
|
|
|
shutil.copytree(app_path, dest_path)
|
|
|
|
|
logger.info(f"Copied app: {app_name}")
|
|
|
|
|
else:
|
|
|
|
|
@ -179,10 +185,25 @@ class GitPusherRequestHandler(BaseHTTPRequestHandler):
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def prepare_git_url(git_url, token):
|
|
|
|
|
"""Préparer l'URL Git avec le token"""
|
|
|
|
|
if git_url.startswith('https://'):
|
|
|
|
|
parts = git_url.replace('https://', '').split('/')
|
|
|
|
|
return f"https://{token}@{'/'.join(parts)}"
|
|
|
|
|
"""Préparer l'URL Git avec le token inséré"""
|
|
|
|
|
logger.info(f"Preparing git URL with token")
|
|
|
|
|
|
|
|
|
|
# Si l'URL contient déjà un token (format: https://user:token@host/repo)
|
|
|
|
|
# on le remplace
|
|
|
|
|
if '@' in git_url:
|
|
|
|
|
# Extraire la partie sans le token
|
|
|
|
|
protocol = git_url.split('://')[0]
|
|
|
|
|
rest = git_url.split('://', 1)[1]
|
|
|
|
|
host_and_path = rest.split('@', 1)[1] if '@' in rest else rest
|
|
|
|
|
return f"{protocol}://{token}@{host_and_path}"
|
|
|
|
|
|
|
|
|
|
# Si l'URL est juste https://host/repo (sans credentials)
|
|
|
|
|
if git_url.startswith('https://') or git_url.startswith('http://'):
|
|
|
|
|
protocol = git_url.split('://')[0]
|
|
|
|
|
host_and_path = git_url.split('://', 1)[1]
|
|
|
|
|
# Insérer le token au format user:token@host ou juste token@host
|
|
|
|
|
return f"{protocol}://{token}@{host_and_path}"
|
|
|
|
|
|
|
|
|
|
return git_url
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|