Reputation: 569
While creating new changelist is there a way that I can create default description template. So whenever I will create new changelist I want some of the details to be pre-populated on my p4 client. Below is an example to prepopulated template that I would like to have:
Summary:
Fix:
Impact:
Testing:
Unit Testing:
Documentation:
QA:
Localization:
Jira-Id:
Upvotes: 1
Views: 2187
Reputation: 1
I'm using the 2023.3 windows perforce client. The following overwrites a given changelist message with some template multiline text:
@echo off
REM Modify P4Client Changelist description
setlocal EnableDelayedExpansion
set change_number=%1
REM Generate description
> temp_description.txt (
echo [JIRA ID]: A short summary of the issue being fixed.
echo Behavior Changes: Briefly explain what has changed in the code behavior.
echo Test Cases: Include the number of unit test cases done.
echo Risk Assessment: Categorize the risk as Low, Medium, or High, with a short explanation.
)
p4 --field "Description=" change -o %change_number% | p4 change -i
for /f "tokens=*" %%a in (temp_description.txt) do (
p4 --field "Description+=%%a" change -o %change_number% | p4 change -i
)
REM Remove the temp file
del temp_description.txt
Copy that into a bat file. Add the bat file to the custom tools in perforce. Have it "prompt for user arguments" so they can pass in the changelist number to operate on. Check "Run tool in terminal Window" this is so it has access to the perforce environment settings. Right click -> Edit Changelist in the UI and the description will refresh to the template you've just set.
Upvotes: 0
Reputation: 71542
To do this for all users on the server, set up a form-out
trigger on the change
form and replace the default template with your own template. The simplest possible version of this is a sed
one-liner:
Triggers:
form-out change "sed -i s/<.*>/fnord/ %formfile%"
You can replace this with something arbitrarily complex (maybe you want to modify the template per user, etc.)
If you want to just do it for yourself on your own client machine, do it in your editor (e.g. have a macro that replaces <enter description here>
with your template). If you can't do it in your editor, you can do it outside your editor by wrapping it in a script that does something like:
sed -i s/<.*>/fnord/ $1
vi $1
and then do:
p4 set P4EDITOR=my-wrapper.sh
Upvotes: 1