|
|
|
|
@@ -29,6 +29,10 @@ from app.utils import randomString
|
|
|
|
|
|
|
|
|
|
class GithubURLMaker:
|
|
|
|
|
def __init__(self, url):
|
|
|
|
|
self.baseUrl = None
|
|
|
|
|
self.user = None
|
|
|
|
|
self.repo = None
|
|
|
|
|
|
|
|
|
|
# Rewrite path
|
|
|
|
|
import re
|
|
|
|
|
m = re.search("^\/([^\/]+)\/([^\/]+)\/?$", url.path)
|
|
|
|
|
@@ -51,6 +55,9 @@ class GithubURLMaker:
|
|
|
|
|
def getScreenshotURL(self):
|
|
|
|
|
return self.baseUrl + "/screenshot.png"
|
|
|
|
|
|
|
|
|
|
def getModConfURL(self):
|
|
|
|
|
return self.baseUrl + "/mod.conf"
|
|
|
|
|
|
|
|
|
|
def getCommitsURL(self, branch):
|
|
|
|
|
return "https://api.github.com/repos/{}/{}/commits?sha={}" \
|
|
|
|
|
.format(self.user, self.repo, urllib.parse.quote_plus(branch))
|
|
|
|
|
@@ -339,8 +346,11 @@ def makeVCSReleaseFromGithub(id, branch, release, url):
|
|
|
|
|
raise TaskError("Invalid github repo URL")
|
|
|
|
|
|
|
|
|
|
commitsURL = urlmaker.getCommitsURL(branch)
|
|
|
|
|
contents = urllib.request.urlopen(commitsURL).read().decode("utf-8")
|
|
|
|
|
commits = json.loads(contents)
|
|
|
|
|
try:
|
|
|
|
|
contents = urllib.request.urlopen(commitsURL).read().decode("utf-8")
|
|
|
|
|
commits = json.loads(contents)
|
|
|
|
|
except HTTPError:
|
|
|
|
|
raise TaskError("Unable to get commits for Github repository. Either the repository or reference doesn't exist.")
|
|
|
|
|
|
|
|
|
|
if len(commits) == 0 or not "sha" in commits[0]:
|
|
|
|
|
raise TaskError("No commits found")
|
|
|
|
|
@@ -349,7 +359,6 @@ def makeVCSReleaseFromGithub(id, branch, release, url):
|
|
|
|
|
release.task_id = None
|
|
|
|
|
release.commit_hash = commits[0]["sha"]
|
|
|
|
|
release.approve(release.package.author)
|
|
|
|
|
print(release.url)
|
|
|
|
|
db.session.commit()
|
|
|
|
|
|
|
|
|
|
return release.url
|
|
|
|
|
|