Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit b82380ffc95c3c8e7058003d1960406f6b37fce5
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Wed Jun 3 14:17:03 2015 +0200
[frontend][rhbz:#1227190] hotfix: restore old route to the repo_file handler
---------------------------------------------------------------
frontend/coprs_frontend/coprs/models.py | 2 +
.../coprs/views/coprs_ns/coprs_general.py | 24 ++++++++++++-------
.../test_views/test_coprs_ns/test_coprs_general.py | 8 +++---
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/models.py
b/frontend/coprs_frontend/coprs/models.py
index 2b77b8e..b66c634 100644
--- a/frontend/coprs_frontend/coprs/models.py
+++ b/frontend/coprs_frontend/coprs/models.py
@@ -196,6 +196,8 @@ class Copr(db.Model, helpers.Serializer):
def check_copr_chroot(self, chroot):
"""
Return object of chroot, if is related to our copr or None
+
+ :type chroot: CoprChroot
"""
result = None
diff --git a/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
b/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
index 70085e1..d8b87c0 100644
--- a/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+++ b/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
@@ -559,22 +559,28 @@ def generate_repo_file(username, coprname, name_release, repofile):
# dash, therefore user-re-po resolves to user-re/po instead of user/re-po
# FAS usernames may not contain dashes, so this construction is safe.
- reponame = "{0}-{1}".format(username, coprname)
-
- if repofile is not None and repofile != username + '-' + coprname +
'-' + name_release + '.repo':
- return page_not_found(
- "Repository filename does not match expected: {0}"
- .format(repofile))
+ reponame = "{}-{}".format(username, coprname)
try:
# query.one() is used since it fetches all builds, unlike
# query.first().
- copr = coprs_logic.CoprsLogic.get(flask.g.user, username, coprname,
- with_builds=True).one()
+ copr = coprs_logic.CoprsLogic.get(flask.g.user, username, coprname,
with_builds=True).one()
except sqlalchemy.orm.exc.NoResultFound:
return page_not_found(
"Project {0}/{1} does not exist".format(username, coprname))
+ # we need to check if we really got name release or it's a full chroot (caused by
old dnf plugin)
+ if name_release in [c.name for c in copr.active_chroots]:
+ chroot = [c for c in copr.active_chroots if c.name == name_release][0]
+ return flask.redirect(flask.url_for(
+ "coprs_ns.generate_repo_file", username=username,
coprname=coprname,
+ name_release=chroot.name_release))
+
+ if repofile is not None and repofile != username + '-' + coprname +
'-' + name_release + '.repo':
+ return page_not_found(
+ "Repository filename does not match expected: {0}"
+ .format(repofile))
+
mock_chroot = coprs_logic.MockChrootsLogic.get_from_name(name_release,
noarch=True).first()
if not mock_chroot:
return page_not_found("Chroot {0} does not
exist".format(name_release))
@@ -587,7 +593,7 @@ def generate_repo_file(username, coprname, name_release, repofile):
if not url:
return page_not_found(
- "Repository not initialized: No finished builds in {0}/{1}."
+ "Repository not initialized: No finished builds in {}/{}."
.format(username, coprname))
repo_url = generate_repo_url(mock_chroot, url)
diff --git a/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
b/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
index 8ecaacc..4696a51 100644
--- a/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
+++ b/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
@@ -699,23 +699,23 @@ class TestCoprRepoGeneration(CoprsTestCase):
assert r.status_code == 404
assert "does not exist" in r.data
- def test_fail_on_no_finished_builds(self, f_users, f_coprs,
+ def test_fail_on_no_finished_builds(self, f_users, f_coprs, f_mock_chroots,
f_not_finished_builds, f_db):
r = self.tc.get(
- "/coprs/{0}/{1}/repo/fedora-18-x86_64/"
+ "/coprs/{0}/{1}/repo/fedora-18/"
.format(self.u1.name, self.c1.name))
assert r.status_code == 404
assert "Repository not initialized" in r.data
- def test_works_on_older_builds(self, f_users, f_coprs,
+ def test_works_on_older_builds(self, f_users, f_coprs, f_mock_chroots,
f_custom_builds, f_db):
from coprs import app
orig = app.config["ENFORCE_PROTOCOL_FOR_BACKEND_URL"]
app.config["ENFORCE_PROTOCOL_FOR_BACKEND_URL"] = "https"
r = self.tc.get(
- "/coprs/{0}/{1}/repo/fedora-18-x86_64/"
+ "/coprs/{0}/{1}/repo/fedora-18/"
.format(self.u1.name, self.c1.name))
assert r.status_code == 200