aboutsummaryrefslogtreecommitdiff
path: root/app/tasks/importtasks.py
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-05-23 18:49:23 +0100
committerrubenwardy <rw@rubenwardy.com>2018-05-23 18:49:23 +0100
commitbd2e7e7a46c5bd241fcbab506fe5b4d3923736e7 (patch)
treea72c1a38f126f9b9b4c27d45b4ee4d2769df60ed /app/tasks/importtasks.py
parentda33b106123ec7595008869398718df3d549bb9d (diff)
downloadcheatdb-bd2e7e7a46c5bd241fcbab506fe5b4d3923736e7.tar.xz
Fix import bugs
Diffstat (limited to 'app/tasks/importtasks.py')
-rw-r--r--app/tasks/importtasks.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/tasks/importtasks.py b/app/tasks/importtasks.py
index 175e8a5..61b60d9 100644
--- a/app/tasks/importtasks.py
+++ b/app/tasks/importtasks.py
@@ -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()