wip: pygit2

This commit is contained in:
Dr.Lt.Data
2024-11-29 19:50:35 +09:00
parent 76b073c366
commit 34a48fbae4
5 changed files with 185 additions and 7 deletions

View File

@@ -2,7 +2,8 @@ import ast
import re
import os
import json
from git import Repo
import sys
from glob import git_wrapper
import concurrent
import datetime
import concurrent.futures
@@ -243,25 +244,27 @@ def get_py_urls_from_json(json_file):
return py_files
import traceback
def clone_or_pull_git_repository(git_url):
repo_name = git_url.split("/")[-1].split(".")[0]
repo_dir = os.path.join(temp_dir, repo_name)
if os.path.exists(repo_dir):
try:
repo = Repo(repo_dir)
repo = git_wrapper.Repo(repo_dir)
origin = repo.remote(name="origin")
origin.pull()
repo.git.submodule('update', '--init', '--recursive')
repo.update_recursive()
print(f"Pulling {repo_name}...")
except Exception as e:
traceback.print_exc()
print(f"Pulling {repo_name} failed: {e}")
else:
try:
Repo.clone_from(git_url, repo_dir, recursive=True)
git_wrapper.clone_from(git_url, repo_dir, recursive=True)
print(f"Cloning {repo_name}...")
except Exception as e:
traceback.print_exc()
print(f"Cloning {repo_name} failed: {e}")