Skip to content
Snippets Groups Projects
Commit 42764d4f authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

add git sync management command

parent 08e7370d
Branches
No related tags found
1 merge request!1Release
Pipeline #12442 passed
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.")
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment