Skip to content

Commit

Permalink
Add: Display sha256 of downloaded files while signing release assets
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bjoernricks committed Jul 4, 2023
1 parent 974a554 commit 2fb138d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pontos/release/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#

import asyncio
import hashlib
import subprocess
from argparse import Namespace
from asyncio.subprocess import Process
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 2fb138d

Please sign in to comment.