~edwargix/git.sr.ht

644d32a4303778c1ad9ffcffe92a2e24b0fb742b — Simon Ser 3 years ago 4b5db16
Strip PGP signature from annotated tag message
3 files changed, 14 insertions(+), 4 deletions(-)

M gitsrht/blueprints/repo.py
M gitsrht/templates/ref.html
M gitsrht/templates/refs.html
M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +12 -2
@@ 495,6 495,14 @@ def patch(owner, repo, ref):
            return "Error preparing patch", 500
        return Response(subp.stdout, mimetype='text/plain')

def strip_pgp_signature(text):
    if not text.strip().endswith("-----END PGP SIGNATURE-----"):
        return text
    i = text.rindex('-----BEGIN PGP SIGNATURE-----')
    if i < 0:
        return text
    return text[:i]

@repo.route("/<owner>/<repo>/refs")
def refs(owner, repo):
    owner, repo = get_repo_or_redir(owner, repo)


@@ 546,7 554,8 @@ def refs(owner, repo):
                owner=owner, repo=repo, tags=tags, branches=branches,
                git_repo=git_repo, isinstance=isinstance, pygit2=pygit2,
                page=page + 1, total_pages=total_pages,
                default_branch=default_branch)
                default_branch=default_branch,
                strip_pgp_signature=strip_pgp_signature)


@repo.route("/<owner>/<repo>/refs/rss.xml")


@@ 593,4 602,5 @@ def ref(owner, repo, ref):
                .filter(Artifact.commit == tag.target.hex)).all()
        return render_template("ref.html", view="refs",
                owner=owner, repo=repo, git_repo=git_repo, tag=tag,
                artifacts=artifacts, default_branch=git_repo.default_branch())
                artifacts=artifacts, default_branch=git_repo.default_branch(),
                strip_pgp_signature=strip_pgp_signature)

M gitsrht/templates/ref.html => gitsrht/templates/ref.html +1 -1
@@ 89,7 89,7 @@
      <div class="event-list">
        <div class="event">
          {% if tag.message %}
          <pre style="padding-bottom: 0;">{{tag.message}}</pre>
          <pre style="padding-bottom: 0;">{{strip_pgp_signature(tag.message)}}</pre>
          {% endif %}
        </div>
      </div>

M gitsrht/templates/refs.html => gitsrht/templates/refs.html +1 -1
@@ 71,7 71,7 @@
            </small>
          </h4>
          {% if tag.message %}
          <pre style="padding-bottom: 0;">{{tag.message}}</pre>
          <pre style="padding-bottom: 0;">{{strip_pgp_signature(tag.message)}}</pre>
          {% endif %}
        </div>
        {% endfor %}