Add support for submodules in makeVCSRelease()

This commit is contained in:
rubenwardy 2020-01-19 00:28:26 +00:00
parent 59039a14a5
commit bcd003685e
2 changed files with 24 additions and 20 deletions

View File

@ -17,6 +17,7 @@
import flask, json, os, git, tempfile, shutil, gitdb import flask, json, os, git, tempfile, shutil, gitdb
from git import GitCommandError from git import GitCommandError
from git_archive_all import GitArchiver
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from urllib.error import HTTPError from urllib.error import HTTPError
import urllib.request import urllib.request
@ -380,18 +381,20 @@ def makeVCSRelease(id, branch):
elif release.package is None: elif release.package is None:
raise TaskError("No package attached to release") raise TaskError("No package attached to release")
urlmaker = None # url = urlparse(release.package.repo)
url = urlparse(release.package.repo) # if url.netloc == "github.com":
if url.netloc == "github.com": # return makeVCSReleaseFromGithub(id, branch, release, url)
return makeVCSReleaseFromGithub(id, branch, release, url)
else:
gitDir, repo = cloneRepo(release.package.repo, ref=branch, recursive=True) gitDir, repo = cloneRepo(release.package.repo, ref=branch, recursive=True)
try: try:
filename = randomString(10) + ".zip" filename = randomString(10) + ".zip"
destPath = os.path.join(app.config["UPLOAD_DIR"], filename) destPath = os.path.join(app.config["UPLOAD_DIR"], filename)
with open(destPath, "wb") as fp:
repo.archive(fp, format="zip") assert(not os.path.isfile(destPath))
archiver = GitArchiver(force_sub=True, main_repo_abspath=gitDir)
archiver.create(destPath)
assert(os.path.isfile(destPath))
release.url = "/uploads/" + filename release.url = "/uploads/" + filename
release.task_id = None release.task_id = None

View File

@ -15,6 +15,7 @@ beautifulsoup4~=4.6
celery==4.1.1 celery==4.1.1
kombu==4.2.0 kombu==4.2.0
GitPython~=2.1 GitPython~=2.1
git-archive-all~=1.20
lxml~=4.2 lxml~=4.2
pillow~=6.2 pillow~=6.2
pyScss~=1.3 pyScss~=1.3