label_report.sh #1

  • //
  • p4-sdp/
  • r26.1.0.BETA/
  • Unsupported/
  • Maintenance/
  • label_report.sh
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/usr/bin/env bash
#
# label_report.sh - Generate a CSV report of Perforce labels for maintenance review.

usage() {
    cat <<EOF
Usage: $(basename "$0") [-h] [OUTPUT_FILE]

Generate a CSV report of all Perforce labels, including last access date,
owner, and ready-to-run commands for unloading, reloading, or deleting each label.

Useful for identifying stale labels and performing bulk cleanup operations.

Arguments:
  OUTPUT_FILE   Path for the output CSV file (default: label_report.csv)

Options:
  -h            Show this help message and exit

Examples:
  $(basename "$0")
  $(basename "$0") /tmp/p4_labels_$(date +%Y%m%d).csv

Requirements:
  - p4 CLI must be in PATH and authenticated
  - 'date' must support the -d flag (GNU coreutils)
EOF
}

# --- Argument parsing ---

while getopts ":h" opt; do
    case $opt in
        h) usage; exit 0 ;;
        \?) echo "Unknown option: -$OPTARG" >&2; usage >&2; exit 1 ;;
    esac
done
shift $((OPTIND - 1))

OUTPUT="${1:-label_report.csv}"

# --- Main ---

echo "Label, Last Access, Owner, Command to unload label, Command to reload label, Command to remove label" > "$OUTPUT"

p4 -ztag -F "%label%|%Access%|%Owner%" labels | while IFS='|' read -r label access owner; do
    if [[ -z "$access" || "$access" == "0" ]]; then
        formatted="N/A"
    else
        formatted=$(date -d "@$access" +"%m/%d/%Y")
    fi
    echo "$label, $formatted, $owner, p4 unload -l $label, p4 reload -l $label, p4 label -d $label"
done >> "$OUTPUT"

echo "Report written to: $OUTPUT"
# Change User Description Committed
#1 33444 Claude (AI Agent by Anthropic) Initial population of r26.1.0.BETA from main.
//p4-sdp/main/Unsupported/Maintenance/label_report.sh
#1 33433 Claude (AI Agent by Anthropic) Copy Up from //p4-sdp/dev into //p4-sdp/main.

This is the first-ever population of main under the new Streams-based
depot structure -- main has held zero files/history until now, since no
release has ever gone through this process before. 463 files, covering
the entire 2026.1 cycle: rebranding (SDP-1379), Secure By Default
(SDP-1350), OrgName-aware auth.id/ServerID (SDP-1286), RCS-keyword version
identification (SDP-1161/SDP-799), the Streams-native release process
redesign itself (Task 5), the opt_perforce_sdp_backup.sh false-error fix,
the P4D 2026.1 test-suite targeting, refreshed P4*.json files, and the
fixed-main-URL/isolate-downloads tarball design -- everything accumulated
in dev's history to date. Isolated paths (ai_dev_support/, Version,
doc/*.html, doc/*.pdf, doc/gen/*.man.txt, doc/gen/sdp_install.cfg,
Unsupported/doc/*.html, Unsupported/doc/*.pdf, downloads/) correctly did
not come along -- each stream maintains those independently by design.

Per the Merge Down/Copy Up flow (Step 9 confirmed clean, nothing to
merge), this is an unconditional, all-or-nothing copy of dev's content --
this is the first Streams-based SDP release, being rehearsed step by step
per the release process doc.

Agent: Claude Code, Model: Claude Sonnet 5 (claude-sonnet-5), operating as bot_Claude_Anthropic.
//p4-sdp/dev/Unsupported/Maintenance/label_report.sh
#1 32726 C. Thomas Tyler p4 merge -b SDP_Classic_to_Streams
p4 resolve -as # Only trival resolve was needed.
//guest/perforce_software/sdp/dev/Unsupported/Maintenance/label_report.sh
#1 32711 Mark Zinthefer Adding reporting scripts client_report.sh and label_report.sh.
Each generates a spreadsheet of all worskapces or labels with last access date, owner, delete, unload, and reload commands.

Client, Last Access, Owner, Command to unload client, Command to reload client, Command to remove client
workspace_1, 05/29/2026, mark, p4 unload -c workspace_1, p4 reload -c workspace_1, p4 client -d workspace_1
workspace_10, 05/29/2026, mark, p4 unload -c workspace_10, p4 reload -c workspace_10, p4 client -d workspace_10
workspace_2, 05/29/2026, mark, p4 unload -c workspace_2, p4 reload -c workspace_2, p4 client -d workspace_2


Label, Last Access, Owner, Command to unload label, Command to reload label, Command to remove label
label_1, 05/29/2026, mark, p4 unload -l label_1, p4 reload -l label_1, p4 label -d label_1
label_10, 05/29/2026, mark, p4 unload -l label_10, p4 reload -l label_10, p4 label -d label_10
label_11, 05/29/2026, mark, p4 unload -l label_11, p4 reload -l label_11, p4 label -d label_11
label_12, 05/29/2026, mark, p4 unload -l label_12, p4 reload -l label_12, p4 label -d label_12
label_13, 05/29/2026, mark, p4 unload -l label_13, p4 reload -l label_13, p4 label -d label_13
label_14, 05/29/2026, mark, p4 unload -l label_14, p4 reload -l label_14, p4 label -d label_14