From 5e7b2734959be6d847b24bcc97f2f3a6fd1a4317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Tue, 4 Jul 2023 14:37:16 +0200 Subject: [PATCH] Add: Display sha256 of downloaded files while signing release assets Show the sha256 hash sum of each downloaded file while doing the release signing. This allows to check if the files have changed in some way. --- pontos/release/sign.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pontos/release/sign.py b/pontos/release/sign.py index 190dc337..f4cf554f 100644 --- a/pontos/release/sign.py +++ b/pontos/release/sign.py @@ -17,6 +17,7 @@ # import asyncio +import hashlib import subprocess from argparse import Namespace from asyncio.subprocess import Process @@ -26,6 +27,7 @@ import httpx from rich.progress import Progress as RichProgress +from rich.progress import TextColumn from pontos.errors import PontosError from pontos.git.git import GitError @@ -88,13 +90,19 @@ async def _async_download_progress( with destination.open("wb") as f: task_description = f"Downloading [blue]{progress.url}" task_id = rich_progress.add_task( - task_description, total=progress.length + task_description, + total=progress.length, + sha256="", ) + sha256 = hashlib.sha256() async for content, percent in progress: rich_progress.advance(task_id, percent or 1) f.write(content) + sha256.update(content) - rich_progress.update(task_id, total=1, completed=1) + rich_progress.update( + task_id, total=1, completed=1, sha256=sha256.hexdigest() + ) async def download_zip( self, @@ -266,7 +274,11 @@ async def run( zip_destination = Path(f"{project}-{release_version}.zip") tarball_destination = Path(f"{project}-{release_version}.tar.gz") - with self.terminal.progress() as rich_progress: + with self.terminal.progress( + additional_columns=[ + TextColumn("[progress.description]{task.fields[sha256]}"), + ] + ) as rich_progress: tasks.append( asyncio.create_task( self.download_zip(