From da0fbf9dd67caaa96e799ac05a609d64a15b814f Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sat, 18 Oct 2025 19:06:27 -0600 Subject: [PATCH] better label handling for snapshots Signed-off-by: Andy Miller --- bin/restore | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/restore b/bin/restore index a0c1e80f6..0a8e7d373 100755 --- a/bin/restore +++ b/bin/restore @@ -124,7 +124,7 @@ function createUpgradeService(array $options): SafeUpgradeService } /** - * @return list + * @return list */ function loadSnapshots(): array { @@ -145,6 +145,7 @@ function loadSnapshots(): array $snapshots[] = [ 'id' => $decoded['id'], + 'label' => $decoded['label'] ?? null, 'source_version' => $decoded['source_version'] ?? null, 'target_version' => $decoded['target_version'] ?? null, 'created_at' => (int)($decoded['created_at'] ?? 0), @@ -155,15 +156,17 @@ function loadSnapshots(): array } /** - * @param list $snapshots + * @param list $snapshots * @return string */ function formatSnapshotListLine(array $snapshot): string { $restoreVersion = $snapshot['source_version'] ?? $snapshot['target_version'] ?? 'unknown'; $timeLabel = formatSnapshotTimestamp($snapshot['created_at']); + $label = $snapshot['label'] ?? null; + $display = $label ? sprintf('%s [%s]', $label, $snapshot['id']) : $snapshot['id']; - return sprintf('%s (restore to Grav %s, %s)', $snapshot['id'], $restoreVersion, $timeLabel); + return sprintf('%s (restore to Grav %s, %s)', $display, $restoreVersion, $timeLabel); } function formatSnapshotTimestamp(int $timestamp): string