使用Phabricator的開發人員,肯定會使用到Audit功能。
Phabricator + Git
在Audit的官方文檔中提到:
If you put Auditors: username1, username2 in your commit message, it will trigger an audit request to those users when you push it to a tracked branch.
然而在實現的使用過程中發現只有提交描述必須以Auditors:….開頭的提交相關人員才能收到審覈請求,這樣寫的結果是在查看git log時首先看到的Auditors:flybeta,…..很長的一串,很時不爽。 如下:
git commit -m “Auditors: flybeta, 張三, 李四…. 修改添加邏輯”
經查看Phabricator源代碼發現(430行):
phabricator/src/applications/audit/editor/PhabricatorAuditEditor.php
private function createAuditRequestTransactionFromCommitMessage(
PhabricatorRepositoryCommit $commit) {
$data = $commit->getCommitData();
$message = $data->getCommitMessage();
$matches = null;
if (!preg_match('/^Auditors?:\s*(.*)$/im', $message, $matches)) {
return array();
}
$phids = id(new PhabricatorObjectListQuery())
->setViewer($this->getActor())
->setAllowPartialResults(true)
->setAllowedTypes(
array(
PhabricatorPeopleUserPHIDType::TYPECONST,
PhabricatorProjectProjectPHIDType::TYPECONST,
))
->setObjectList($matches[1])
->execute();
if (!$phids) {
return array();
}
foreach ($phids as $phid) {
$this->addAuditReason($phid, pht('Requested by Author'));
}
return id(new PhabricatorAuditTransaction())
->setTransactionType(PhabricatorAuditActionConstants::ADD_AUDITORS)
->setNewValue(array_fuse($phids));
}
此處正則匹配時就是以Auditors:….開始截取的,所以只需要修改此處就可以了。