#!/bin/bash
set -u
# Install in triggers table wtih a pair of entries like this:
# Triggers:
# RestrictedCL form-in change "/p4/common/site/bin/triggers/change_form_to_restricted.sh %formfile%"
# RestrictedCL change-commit //... "/p4/common/site/bin/triggers/change_form_to_restricted.sh %changelist%"
# This will take either a changelist number (all numeric) or a temp file path (the form file), and make
# adjustments as needed to ensure all changelists are restricted. This works in conjunction with having
# the 'defaultChangeType' configurable set to 'restricted'. This script ensures there is no sneaking around
# the policy.
# Future Proofing consideration: Currently, the only possible values for the Type field of a changelist
# are 'public' and 'restricted'. This is not expected to change. If it ever did for some reason, this
# code would need review.
declare -i ErrorCount=0
declare Parameter=${1:-}
declare FormFile=
declare Changelist=
declare TmpFile=
function msg () { echo -e "$*"; }
function errmsg () { msg "\\nError: ${1:-Unknown Error}\\n"; ErrorCount+=1; }
function bail () { errmsg "${1:-Unknown Error}"; exit "$ErrorCount"; }
# shellcheck disable=SC1091
source /p4/common/bin/p4_vars "${SDP_INSTANCE:-1}"
if [[ -n "$Parameter" ]]; then
if [[ "$Parameter" =~ ^[0-9]+$ ]]; then
Changelist="$Parameter"
else
FormFile="$Parameter"
fi
else
bail "Bad usage: A single parameter, '<FormFile>' or '<Changelist>', is required."
fi
if [[ -n "$FormFile" ]]; then
[[ -r "$FormFile" ]] || bail "FormFile $FormFile does not exist."
if grep -E -q '^Type:\s*public' "$FormFile"; then
sed -E -i -e 's/^Type:.*$/Type: restricted/g' "$FormFile"
fi
else # Deal with submitted CL.
# Ensure change type is restricted.
TmpFile=$(mktemp)
p4 change -o "$Changelist" > "$TmpFile" ||\
bail "Could not do: p4 change -o $Changelist"
if grep -E -q '^Type:\s*public' "$TmpFile"; then
p4 --field Type=restricted change -o "$Changelist" | p4 change -f -i
fi
rm -f "$TmpFile"
fi
exit 0
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #1 | 33444 | Claude (AI Agent by Anthropic) | Initial population of r26.1.0.BETA from main. | ||
| //p4-sdp/main/Unsupported/Samples/triggers/change_form_to_restricted.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/Samples/triggers/change_form_to_restricted.sh | |||||
| #1 | 32138 | C. Thomas Tyler | p4 merge -b SDP_Classic_to_Streams && p4 resolve -as && p4 resolve -at //p4-sdp/dev/Server/Unix/p4/common/lib/run.lib | ||
| //guest/perforce_software/sdp/dev/Unsupported/Samples/triggers/change_form_to_restricted.sh | |||||
| #3 | 32019 | C. Thomas Tyler | Shellcheck fixes. | ||
| #2 | 32018 | C. Thomas Tyler |
Fixed to work with any SDP instance name. Fixed error messages. dos2unix |
||
| #1 | 32017 | C. Thomas Tyler | Added script to keep public changes. | ||