diff --git a/pagure/docs_server.py b/pagure/docs_server.py index a72331d..d1f9cc1 100644 --- a/pagure/docs_server.py +++ b/pagure/docs_server.py @@ -158,7 +158,14 @@ def view_docs(repo, username=None, namespace=None, filename=None): if not repo_obj.is_empty: commit = repo_obj[repo_obj.head.target] else: - flask.abort(404, 'No content found is the repository') + flask.abort( + 404, + flask.Markup( + 'No content found is the repository, you may want to read ' + 'the ' + 'Using the doc repository of your project documentation' + ) + ) branchname = 'master' content = None diff --git a/tests/test_pagure_flask_docs.py b/tests/test_pagure_flask_docs.py index 8930885..0715734 100644 --- a/tests/test_pagure_flask_docs.py +++ b/tests/test_pagure_flask_docs.py @@ -154,6 +154,26 @@ class PagureFlaskDocstests(tests.Modeltests): output = self.app.get('/test/docs', follow_redirects=True) self.assertEqual(output.status_code, 404) + def test_view_docs_empty_repo(self): + """ Test the view_docs endpoint when the git repo is empty. """ + tests.create_projects(self.session) + repo = pygit2.init_repository( + os.path.join(self.path, 'docs', 'test.git'), bare=True) + + # Turn on the docs project since it's off by default + repo = pagure.get_authorized_project(self.session, 'test') + repo.settings = {'project_documentation': True} + self.session.add(repo) + self.session.commit() + + output = self.app.get('/test/docs') + self.assertEqual(output.status_code, 404) + self.assertIn( + '

No content found is the repository, you may want to read ' + 'the Using the doc repository of your project ' + 'documentation

', output.data) + def test_view_docs(self): """ Test the view_docs endpoint. """ tests.create_projects(self.session)