From 0bb2277e2604abd8227ec46f4cc90faf4e579245 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Mon, 11 Nov 2024 12:27:00 -0800 Subject: [PATCH] BREAKING: Add the ability to download and extract to a temp dir This also will execute any --exec scripts from the dest directory --- release_gitter.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/release_gitter.py b/release_gitter.py index e75a75c..499c84b 100755 --- a/release_gitter.py +++ b/release_gitter.py @@ -3,6 +3,7 @@ from __future__ import annotations import argparse import platform +import tempfile from collections.abc import Sequence from dataclasses import dataclass from io import BytesIO @@ -552,6 +553,12 @@ def _parse_args(args: list[str] | None = None) -> argparse.Namespace: action="store_true", help="Only print the URL and do not download", ) + parser.add_argument( + "--use-temp-dir", + "-t", + action="store_true", + help="Use a temporary directory as the destination", + ) parsed_args = parser.parse_args(args) @@ -576,6 +583,9 @@ def _parse_args(args: list[str] | None = None) -> argparse.Namespace: if parsed_args.extract_all: parsed_args.extract_files = [] + if parsed_args.use_temp_dir: + parsed_args.destination = Path(tempfile.mkdtemp()) + return parsed_args @@ -683,7 +693,11 @@ def main(): # Optionally execute post command if args.exec: - check_call(args.exec.format(asset["name"], **format_fields), shell=True) + check_call( + args.exec.format(asset["name"], **format_fields), + shell=True, + cwd=args.destination, + ) if __name__ == "__main__":