From b20c7e0cb5ac31d8fecffec3d0f50ac83e6d16d3 Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Tue, 22 Sep 2026 21:39:48 -0300 Subject: [PATCH] feature: include author email in report, generate report filename --- src/git_flow/command/branch/clean.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/git_flow/command/branch/clean.py b/src/git_flow/command/branch/clean.py index 7c44b16..d7ec7b1 100644 --- a/src/git_flow/command/branch/clean.py +++ b/src/git_flow/command/branch/clean.py @@ -1,4 +1,5 @@ import csv +import datetime from dataclasses import dataclass from typing import Annotated @@ -8,7 +9,7 @@ from git_flow import GitFlowError from git_flow.command import base from git_flow.git import Git -REPORT_FORMAT = "%(refname:short)\t%(objectname)\t%(authorname)\t%(authordate:iso-strict)" +REPORT_FORMAT = "%(refname:short)\t%(objectname)\t%(author)\t%(authordate:iso-strict)" REPORT_FILENAME = "branch-clean-report.csv" app = typer.Typer() @@ -48,12 +49,12 @@ def clean( if not base.io_confirm(f"¿Eliminar {len(branches)} rama(s)?", False): raise GitFlowError("Ejecución abortada") - write_report(branches) + report = write_report(branches) for branch in branches: delete_branch(branch, remote) - base.io_success(f"Se eliminaron {len(branches)} rama(s). Reporte generado en {REPORT_FILENAME}") + base.io_success(f"Se eliminaron {len(branches)} rama(s). Reporte generado en {report}") def get_local_branches() -> list[BranchInfo]: @@ -97,14 +98,19 @@ def parse_branch(line: str) -> BranchInfo: return BranchInfo(name, sha, author, date) -def write_report(branches: list[BranchInfo]): - with open(REPORT_FILENAME, "w", newline="") as f: +def write_report(branches: list[BranchInfo]) -> str: + now = datetime.datetime.now().strftime("%Y%m%d%H%M%S") + report = "branch-clean-report-" + now + ".csv" + + with open(report, "w", newline="") as f: writer = csv.writer(f) - writer.writerow(["name", "commit sha", "author", "date"]) + writer.writerow(["name", "commit", "author", "date"]) for branch in branches: writer.writerow([branch.name, branch.sha, branch.author, branch.date]) + return report + def delete_branch(branch: BranchInfo, remote: bool): if remote: