Fix import bugs

This commit is contained in:
rubenwardy 2018-05-23 18:49:23 +01:00
parent da33b10612
commit bd2e7e7a46
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C

@ -34,9 +34,9 @@ class GithubURLMaker:
return
user = m.group(1)
repo = m.group(2)
repo = m.group(2).replace(".git", "")
self.baseUrl = "https://raw.githubusercontent.com/{}/{}/master" \
.format(user, repo.replace(".git", ""))
.format(user, repo)
self.user = user
self.repo = repo
@ -213,13 +213,15 @@ def makeVCSRelease(id, branch):
if not urlmaker.isValid():
raise TaskError("Invalid github repo URL")
contents = urllib.request.urlopen(urlmaker.getCommitsURL(branch)).read().decode("utf-8")
commitsURL = urlmaker.getCommitsURL(branch)
contents = urllib.request.urlopen(commitsURL).read().decode("utf-8")
commits = json.loads(contents)
if len(commits) == 0:
if len(commits) == 0 or not "sha" in commits[0]:
raise TaskError("No commits found")
release.url = urlmaker.getCommitDownload(commits[0]["sha"])
print(release.url)
release.task_id = None
db.session.commit()