diff --git a/contracts/management/__init__.py b/contracts/management/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/contracts/management/commands/__init__.py b/contracts/management/commands/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/contracts/management/commands/import_old_contracts.py b/contracts/management/commands/import_old_contracts.py new file mode 100644 index 0000000000000000000000000000000000000000..0c12660994ba6026c9a7b33e1507b1759d2b65b0 --- /dev/null +++ b/contracts/management/commands/import_old_contracts.py @@ -0,0 +1,50 @@ +import os + +from django.conf import settings +from django.core.management.base import BaseCommand +from git import Repo +from markdown import Markdown + + +class Command(BaseCommand): + help = "Sync contract data from a remote Git repository." + + def add_arguments(self, parser): + parser.add_argument( + "repo_url", + type=str, + help="URL of the Git repository to clone", + ) + parser.add_argument( + "branch", + type=str, + help="Branch to use", + ) + parser.add_argument( + "--directory", + type=str, + help="Directory to store the cloned repository in", + ) + + def handle(self, *args, **options): + git_dir = os.path.join( + os.getcwd(), + ( + options["directory"] + if options["directory"] is not None + else "git" + ) + ) + + Repo.clone_from( + options["repo_url"], + git_dir, + branch=options["branch"], + ) + + md = markdown.Markdown(extensions=['meta']) + parsed_metadata = md.convert("").Meta + + + + self.stdout.write("\nGit repository sync complete.") diff --git a/requirements/base.txt b/requirements/base.txt index a1283e8149633aef51fc6123449f7a5137098f55..39653cd5c070b3e48443e667ed43630780fbd4df 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -15,4 +15,6 @@ django-markdownx==4.0.0b1 django-environ==0.9.0 django-http-exceptions==1.4.0 django-guardian==2.4.0 +GitPython==3.1.31 +Markdown==3.4.3 PyJWT==2.6.0