4 * Groups a set of push logs corresponding to changes which were all pushed in
5 * the same transaction.
7 final class PhabricatorRepositoryPushEvent
8 extends PhabricatorRepositoryDAO
9 implements PhabricatorPolicyInterface
{
11 protected $repositoryPHID;
13 protected $pusherPHID;
14 protected $requestIdentifier;
15 protected $remoteAddress;
16 protected $remoteProtocol;
17 protected $rejectCode;
18 protected $rejectDetails;
24 private $repository = self
::ATTACHABLE
;
25 private $logs = self
::ATTACHABLE
;
27 public static function initializeNewEvent(PhabricatorUser
$viewer) {
28 return id(new PhabricatorRepositoryPushEvent())
29 ->setPusherPHID($viewer->getPHID());
32 protected function getConfiguration() {
34 self
::CONFIG_AUX_PHID
=> true,
35 self
::CONFIG_TIMESTAMPS
=> false,
36 self
::CONFIG_COLUMN_SCHEMA
=> array(
37 'requestIdentifier' => 'bytes12?',
38 'remoteAddress' => 'ipaddress?',
39 'remoteProtocol' => 'text32?',
40 'rejectCode' => 'uint32',
41 'rejectDetails' => 'text64?',
42 'writeWait' => 'uint64?',
43 'readWait' => 'uint64?',
44 'hostWait' => 'uint64?',
45 'hookWait' => 'uint64?',
47 self
::CONFIG_KEY_SCHEMA
=> array(
48 'key_repository' => array(
49 'columns' => array('repositoryPHID'),
51 'key_identifier' => array(
52 'columns' => array('requestIdentifier'),
54 'key_reject' => array(
55 'columns' => array('rejectCode', 'rejectDetails'),
58 ) + parent
::getConfiguration();
61 public function generatePHID() {
62 return PhabricatorPHID
::generateNewPHID(
63 PhabricatorRepositoryPushEventPHIDType
::TYPECONST
);
66 public function attachRepository(PhabricatorRepository
$repository) {
67 $this->repository
= $repository;
71 public function getRepository() {
72 return $this->assertAttached($this->repository
);
75 public function attachLogs(array $logs) {
80 public function getLogs() {
81 return $this->assertAttached($this->logs
);
84 public function saveWithLogs(array $logs) {
85 assert_instances_of($logs, 'PhabricatorRepositoryPushLog');
87 $this->openTransaction();
89 foreach ($logs as $log) {
90 $log->setPushEventPHID($this->getPHID());
93 $this->saveTransaction();
95 $this->attachLogs($logs);
100 /* -( PhabricatorPolicyInterface )----------------------------------------- */
103 public function getCapabilities() {
105 PhabricatorPolicyCapability
::CAN_VIEW
,
109 public function getPolicy($capability) {
110 return $this->getRepository()->getPolicy($capability);
113 public function hasAutomaticCapability($capability, PhabricatorUser
$viewer) {
114 return $this->getRepository()->hasAutomaticCapability($capability, $viewer);
117 public function describeAutomaticCapability($capability) {
119 "A repository's push events are visible to users who can see the ".