此p4python代碼的片段獲取perforce描述並刪除說明中提及的方括號。我打算在更改提交觸發器期間調用此腳本以在提交更改之前替換CL描述。不知道什麼是錯的,但觸發器不採取我的新變化描述..有沒有人嘗試使用p4python這樣做?任何提示的高度讚賞p4python修改更改列表說明
describe = p4.run('describe', changeList)
print describe
description = describe[0].get('desc')
print description
description = description.replace('[', '')
description = description.replace(']', '')
print description
首先描述打印
[{'status': 'pending', 'changeType': 'public', 'rev': ['21'], 'client': 'workspace1', 'user': 'username', 'time': '1432010818', 'action': ['edit'], 'type': ['text'], 'depotFile': ['//depot/repo/Vagrantfile'], 'change': '12345', 'desc': '[ABC-789] testfile commit'}]
首先說明打印
[ABC-789] testfile commit
其次說明刪除的方括號
ABC-789 testfile commit
感謝修正布萊恩..你SRE的權利..我的意思更改內容 – thunderbird
你應該能夠改變更改提交觸發器期間的更改列表描述。但僅僅在Python程序中改變'description'變量是不夠的,而且它不足以將更新後的描述打印到stdout。您需要運行「更改-i」命令,並將修改規範修改爲包含修訂後的更改列表描述(但更改列表規範的其餘部分未更改)。 –