From 7c59e948e3e8e7cc7a34175a4daf4cc1d73548f9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 25 2019 16:14:34 +0000 Subject: Increase logging and support the reference returning a commit We had a case where the reference given wasn't pointing to a tag but to a commit. Which as a matter of fact, is fine since when we are given a tag we want to go to the underlying commit. So if we're given a commit, keep going. Fixes https://pagure.io/pagure/issue/4278 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index d672be1..fd4881a 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -2729,6 +2729,7 @@ def generate_archive(project, commit, tag, name, archive_fmt): archive_folder, project.fullname, tag_path, commit ) if not os.path.exists(target_path): + _log.info("Creating folder: %s", target_path) os.makedirs(target_path) fullpath = os.path.join(target_path, name) diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 15afad5..b31cc56 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -3443,9 +3443,13 @@ def generate_project_archive( if ref_string in repo_obj.listall_references(): reference = repo_obj.lookup_reference(ref_string) tag = repo_obj[reference.target] - if not isinstance(tag, pygit2.Tag): + if isinstance(tag, pygit2.Tag): + commit = tag.peel(pygit2.Commit) + elif isinstance(tag, pygit2.Commit): + commit = tag + else: + _log.debug("Found %s instead of a tag", tag) flask.abort(400, "Invalid reference provided") - commit = tag.peel(pygit2.Commit) else: try: commit = repo_obj.get(ref)