From cef4926e12ad7d6154db8804f205414c63bb565d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Nov 21 2018 15:47:19 +0000 Subject: Inform the user when the identifier provided could not be found When what was provided could not be found in the list of branches or in the repository (ie: it's neither a commit/tree nor a tag), then go back to the default and inform the user that the input was invalid. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 73ddfae..1ea7dd2 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -960,8 +960,13 @@ def view_tree(repo, identifier=None, username=None, namespace=None): except (ValueError, TypeError): # If it's not a commit id then it's part of the filename if not repo_obj.head_is_unborn: - commit = repo_obj[repo_obj.head.target] 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 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):