SIENTIAPDE-994
Remove unused utility files and update requirements.txt to include new dependencies for data processing and database interaction.
This commit is contained in:
30
laborious/utils/git_clone.py
Normal file
30
laborious/utils/git_clone.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
from git import Repo
|
||||
from urllib.parse import quote
|
||||
|
||||
# Lê variáveis de ambiente
|
||||
GIT_TOKEN = os.getenv("GIT_TOKEN")
|
||||
GIT_EMAIL = os.getenv("GIT_EMAIL")
|
||||
REPO_URL = os.getenv("REPO_URL") # ex: "github.com/usuario/repositorio.git"
|
||||
CLONE_DIR = os.getenv("CLONE_DIR", "./repo_clonado")
|
||||
|
||||
if not GIT_TOKEN or not GIT_EMAIL or not REPO_URL:
|
||||
raise EnvironmentError("As variáveis GIT_TOKEN, GIT_EMAIL e REPO_URL devem estar definidas.")
|
||||
|
||||
# Escapa o token (caso contenha caracteres especiais)
|
||||
safe_token = quote(GIT_TOKEN)
|
||||
|
||||
# Monta URL com autenticação via token
|
||||
repo_url_with_auth = f"https://{safe_token}@{REPO_URL}"
|
||||
|
||||
# Clona o repositório
|
||||
print(f"Clonando repositório em {CLONE_DIR}...")
|
||||
Repo.clone_from(repo_url_with_auth, CLONE_DIR)
|
||||
print("Repositório clonado com sucesso.")
|
||||
|
||||
# Opcional: configura o e-mail globalmente no Git (ou dentro do repo)
|
||||
repo = Repo(CLONE_DIR)
|
||||
with repo.config_writer() as git_config:
|
||||
git_config.set_value("user", "email", GIT_EMAIL)
|
||||
|
||||
print(f"E-mail configurado como {GIT_EMAIL}.")
|
||||
Reference in New Issue
Block a user