diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index bc95201..3f659dc 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -962,11 +962,12 @@ def view_tree(repo, identifier=None, username=None, namespace=None): if not repo_obj.head_is_unborn: branchname = repo_obj.head.shorthand commit = repo_obj[repo_obj.head.target] - flask.flash( - "'%s' not found in the git repository, going back to: " - "%s" % (identifier, branchname), - "error", - ) + if identifier: + flask.flash( + "'%s' not found in the git repository, going back " + "to: %s" % (identifier, branchname), + "error", + ) # If we're arriving here from the release page, we may have a Tag # where we expected a commit, in this case, get the actual commit if isinstance(commit, pygit2.Tag): diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 1e89014..ab86f71 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -3175,6 +3175,30 @@ index 0000000..fb7093d self.assertFalse( 'No content found in this repository' in output_text) + # View tree, no identifier: + output = self.app.get('/test/tree/') + self.assertEqual(output.status_code, 200) + output_text = output.get_data(as_text=True) + self.assertIn('