Consistently render and link to discovered-signed format of archive
We linked to and served .tar.asc but the archive link both said .tar.gz and /linked/ to .tar.gz. We never linked to .tar, or even exposed the possibility.
This commit is contained in:
parent
4de526de53
commit
e7fb739535
|
@ -436,8 +436,9 @@ def blame(owner, repo, ref, path):
|
|||
editorconfig=EditorConfig(git_repo, orig_commit.tree, path),
|
||||
lookup_user=lookup_user(), pygit2=pygit2)
|
||||
|
||||
@repo.route("/<owner>/<repo>/archive/<path:ref>.tar.gz")
|
||||
def archive(owner, repo, ref):
|
||||
@repo.route("/<owner>/<repo>/archive/<path:ref>.tar.gz", defaults = {"fmt": "tar.gz"})
|
||||
@repo.route("/<owner>/<repo>/archive/<path:ref>.<any('tar.gz','tar'):fmt>")
|
||||
def archive(owner, repo, ref, fmt):
|
||||
owner, repo = get_repo_or_redir(owner, repo)
|
||||
with GitRepository(repo.path) as git_repo:
|
||||
commit, ref, _ = lookup_ref(git_repo, ref, None)
|
||||
|
@ -449,7 +450,7 @@ def archive(owner, repo, ref):
|
|||
"git",
|
||||
"--git-dir", repo.path,
|
||||
"archive",
|
||||
"--format=tar.gz",
|
||||
"--format", fmt,
|
||||
"--prefix", f"{repo.name}-{refname}/",
|
||||
"--",
|
||||
ref
|
||||
|
@ -457,7 +458,7 @@ def archive(owner, repo, ref):
|
|||
subp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=sys.stderr)
|
||||
|
||||
return send_file(subp.stdout, mimetype="application/tar+gzip",
|
||||
as_attachment=True, download_name=f"{repo.name}-{refname}.tar.gz")
|
||||
as_attachment=True, download_name=f"{repo.name}-{refname}.{fmt}")
|
||||
|
||||
@repo.route("/<owner>/<repo>/archive/<path:ref>.<any('tar.gz','tar'):fmt>.asc")
|
||||
def archivesig(owner, repo, ref, fmt):
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
class="btn btn-primary btn-block"
|
||||
href="{{url_for("repo.archive",
|
||||
owner=repo.owner.canonical_name,
|
||||
repo=repo.name, ref=tag.name)}}"
|
||||
>.tar.gz {{icon("caret-right")}}</a>
|
||||
repo=repo.name, ref=tag.name, fmt=signature or "tar.gz")}}"
|
||||
>.{{ signature or "tar.gz" }} {{icon("caret-right")}}</a>
|
||||
{% if signature %}
|
||||
<a
|
||||
class="btn btn-default btn-block"
|
||||
href="{{url_for("repo.archivesig",
|
||||
owner=repo.owner.canonical_name,
|
||||
repo=repo.name, ref=tag.name, fmt=signature)}}"
|
||||
>.tar.gz.asc {{icon("caret-right")}}</a>
|
||||
>.{{ signature }}.asc {{icon("caret-right")}}</a>
|
||||
{% endif %}
|
||||
<a
|
||||
class="btn btn-default btn-block"
|
||||
|
|
|
@ -56,9 +56,9 @@
|
|||
style="margin-left: 0.5rem"
|
||||
href="{{url_for("repo.archive",
|
||||
owner=repo.owner.canonical_name,
|
||||
repo=repo.name, ref=refname)}}"
|
||||
repo=repo.name, ref=refname, fmt=sig_fmt or "tar.gz")}}"
|
||||
rel="nofollow"
|
||||
>.tar.gz {{icon("caret-right")}}</a>
|
||||
>.{{ sig_fmt or "tar.gz" }} {{icon("caret-right")}}</a>
|
||||
{% if sig_fmt %}
|
||||
<a
|
||||
style="margin-left: 0.5rem"
|
||||
|
|
|
@ -75,9 +75,15 @@
|
|||
repo=repo.name, ref=latest_tag[0][len("refs/tags/"):])}}"
|
||||
>browse {{icon("caret-right")}}</a>
|
||||
<a href="{{url_for("repo.archive", owner=repo.owner.canonical_name,
|
||||
repo=repo.name, ref=latest_tag[0][len("refs/tags/"):])}}"
|
||||
repo=repo.name, ref=latest_tag[0][len("refs/tags/"):], fmt=signature or "tar.gz")}}"
|
||||
rel="nofollow"
|
||||
>.tar.gz {{icon("caret-right")}}</a>
|
||||
>.{{ signature or "tar.gz" }} {{icon("caret-right")}}</a>
|
||||
{% if signature %}
|
||||
<a href="{{url_for("repo.archivesig", owner=repo.owner.canonical_name,
|
||||
repo=repo.name, ref=latest_tag[0][len("refs/tags/"):], fmt=signature)}}"
|
||||
rel="nofollow"
|
||||
>.asc {{icon("caret-right")}}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</dd>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue