[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorRepositoryTransaction 4 extends PhabricatorApplicationTransaction { 5 6 const TYPE_VCS = 'repo:vcs'; 7 const TYPE_ACTIVATE = 'repo:activate'; 8 const TYPE_NAME = 'repo:name'; 9 const TYPE_DESCRIPTION = 'repo:description'; 10 const TYPE_ENCODING = 'repo:encoding'; 11 const TYPE_DEFAULT_BRANCH = 'repo:default-branch'; 12 const TYPE_TRACK_ONLY = 'repo:track-only'; 13 const TYPE_AUTOCLOSE_ONLY = 'repo:autoclose-only'; 14 const TYPE_SVN_SUBPATH = 'repo:svn-subpath'; 15 const TYPE_UUID = 'repo:uuid'; 16 const TYPE_NOTIFY = 'repo:notify'; 17 const TYPE_AUTOCLOSE = 'repo:autoclose'; 18 const TYPE_REMOTE_URI = 'repo:remote-uri'; 19 const TYPE_LOCAL_PATH = 'repo:local-path'; 20 const TYPE_HOSTING = 'repo:hosting'; 21 const TYPE_PROTOCOL_HTTP = 'repo:serve-http'; 22 const TYPE_PROTOCOL_SSH = 'repo:serve-ssh'; 23 const TYPE_PUSH_POLICY = 'repo:push-policy'; 24 const TYPE_CREDENTIAL = 'repo:credential'; 25 const TYPE_DANGEROUS = 'repo:dangerous'; 26 const TYPE_CLONE_NAME = 'repo:clone-name'; 27 28 // TODO: Clean up these legacy transaction types. 29 const TYPE_SSH_LOGIN = 'repo:ssh-login'; 30 const TYPE_SSH_KEY = 'repo:ssh-key'; 31 const TYPE_SSH_KEYFILE = 'repo:ssh-keyfile'; 32 const TYPE_HTTP_LOGIN = 'repo:http-login'; 33 const TYPE_HTTP_PASS = 'repo:http-pass'; 34 35 public function getApplicationName() { 36 return 'repository'; 37 } 38 39 public function getApplicationTransactionType() { 40 return PhabricatorRepositoryRepositoryPHIDType::TYPECONST; 41 } 42 43 public function getApplicationTransactionCommentObject() { 44 return null; 45 } 46 47 public function getRequiredHandlePHIDs() { 48 $phids = parent::getRequiredHandlePHIDs(); 49 50 $old = $this->getOldValue(); 51 $new = $this->getNewValue(); 52 53 switch ($this->getTransactionType()) { 54 case self::TYPE_PUSH_POLICY: 55 $phids[] = $old; 56 $phids[] = $new; 57 break; 58 } 59 60 return $phids; 61 } 62 63 public function shouldHide() { 64 $old = $this->getOldValue(); 65 $new = $this->getNewValue(); 66 67 switch ($this->getTransactionType()) { 68 case self::TYPE_REMOTE_URI: 69 case self::TYPE_SSH_LOGIN: 70 case self::TYPE_SSH_KEY: 71 case self::TYPE_SSH_KEYFILE: 72 case self::TYPE_HTTP_LOGIN: 73 case self::TYPE_HTTP_PASS: 74 // Hide null vs empty string changes. 75 return (!strlen($old) && !strlen($new)); 76 case self::TYPE_LOCAL_PATH: 77 case self::TYPE_NAME: 78 // Hide these on create, they aren't interesting and we have an 79 // explicit "create" transaction. 80 if (!strlen($old)) { 81 return true; 82 } 83 break; 84 } 85 86 return parent::shouldHide(); 87 } 88 89 public function getIcon() { 90 switch ($this->getTransactionType()) { 91 case self::TYPE_VCS: 92 return 'fa-plus'; 93 } 94 return parent::getIcon(); 95 } 96 97 public function getColor() { 98 switch ($this->getTransactionType()) { 99 case self::TYPE_VCS: 100 return 'green'; 101 } 102 return parent::getIcon(); 103 } 104 105 public function getTitle() { 106 $author_phid = $this->getAuthorPHID(); 107 108 $old = $this->getOldValue(); 109 $new = $this->getNewValue(); 110 111 switch ($this->getTransactionType()) { 112 case self::TYPE_VCS: 113 return pht( 114 '%s created this repository.', 115 $this->renderHandleLink($author_phid)); 116 case self::TYPE_ACTIVATE: 117 if ($new) { 118 return pht( 119 '%s activated this repository.', 120 $this->renderHandleLink($author_phid)); 121 } else { 122 return pht( 123 '%s deactivated this repository.', 124 $this->renderHandleLink($author_phid)); 125 } 126 case self::TYPE_NAME: 127 return pht( 128 '%s renamed this repository from "%s" to "%s".', 129 $this->renderHandleLink($author_phid), 130 $old, 131 $new); 132 case self::TYPE_DESCRIPTION: 133 return pht( 134 '%s updated the description of this repository.', 135 $this->renderHandleLink($author_phid)); 136 case self::TYPE_ENCODING: 137 if (strlen($old) && !strlen($new)) { 138 return pht( 139 '%s removed the "%s" encoding configured for this repository.', 140 $this->renderHandleLink($author_phid), 141 $old); 142 } else if (strlen($new) && !strlen($old)) { 143 return pht( 144 '%s set the encoding for this repository to "%s".', 145 $this->renderHandleLink($author_phid), 146 $new); 147 } else { 148 return pht( 149 '%s changed the repository encoding from "%s" to "%s".', 150 $this->renderHandleLink($author_phid), 151 $old, 152 $new); 153 } 154 case self::TYPE_DEFAULT_BRANCH: 155 if (!strlen($new)) { 156 return pht( 157 '%s removed "%s" as the default branch.', 158 $this->renderHandleLink($author_phid), 159 $old); 160 } else if (!strlen($old)) { 161 return pht( 162 '%s set the default branch to "%s".', 163 $this->renderHandleLink($author_phid), 164 $new); 165 } else { 166 return pht( 167 '%s changed the default branch from "%s" to "%s".', 168 $this->renderHandleLink($author_phid), 169 $old, 170 $new); 171 } 172 break; 173 case self::TYPE_TRACK_ONLY: 174 if (!$new) { 175 return pht( 176 '%s set this repository to track all branches.', 177 $this->renderHandleLink($author_phid)); 178 } else if (!$old) { 179 return pht( 180 '%s set this repository to track branches: %s.', 181 $this->renderHandleLink($author_phid), 182 implode(', ', $new)); 183 } else { 184 return pht( 185 '%s changed track branches from "%s" to "%s".', 186 $this->renderHandleLink($author_phid), 187 implode(', ', $old), 188 implode(', ', $new)); 189 } 190 break; 191 case self::TYPE_AUTOCLOSE_ONLY: 192 if (!$new) { 193 return pht( 194 '%s set this repository to autoclose on all branches.', 195 $this->renderHandleLink($author_phid)); 196 } else if (!$old) { 197 return pht( 198 '%s set this repository to autoclose on branches: %s.', 199 $this->renderHandleLink($author_phid), 200 implode(', ', $new)); 201 } else { 202 return pht( 203 '%s changed autoclose branches from "%s" to "%s".', 204 $this->renderHandleLink($author_phid), 205 implode(', ', $old), 206 implode(', ', $new)); 207 } 208 break; 209 case self::TYPE_UUID: 210 if (!strlen($new)) { 211 return pht( 212 '%s removed "%s" as the repository UUID.', 213 $this->renderHandleLink($author_phid), 214 $old); 215 } else if (!strlen($old)) { 216 return pht( 217 '%s set the repository UUID to "%s".', 218 $this->renderHandleLink($author_phid), 219 $new); 220 } else { 221 return pht( 222 '%s changed the repository UUID from "%s" to "%s".', 223 $this->renderHandleLink($author_phid), 224 $old, 225 $new); 226 } 227 break; 228 case self::TYPE_SVN_SUBPATH: 229 if (!strlen($new)) { 230 return pht( 231 '%s removed "%s" as the Import Only path.', 232 $this->renderHandleLink($author_phid), 233 $old); 234 } else if (!strlen($old)) { 235 return pht( 236 '%s set the repository to import only "%s".', 237 $this->renderHandleLink($author_phid), 238 $new); 239 } else { 240 return pht( 241 '%s changed the import path from "%s" to "%s".', 242 $this->renderHandleLink($author_phid), 243 $old, 244 $new); 245 } 246 break; 247 case self::TYPE_NOTIFY: 248 if ($new) { 249 return pht( 250 '%s enabled notifications and publishing for this repository.', 251 $this->renderHandleLink($author_phid)); 252 } else { 253 return pht( 254 '%s disabled notifications and publishing for this repository.', 255 $this->renderHandleLink($author_phid)); 256 } 257 break; 258 case self::TYPE_AUTOCLOSE: 259 if ($new) { 260 return pht( 261 '%s enabled autoclose for this repository.', 262 $this->renderHandleLink($author_phid)); 263 } else { 264 return pht( 265 '%s disabled autoclose for this repository.', 266 $this->renderHandleLink($author_phid)); 267 } 268 break; 269 case self::TYPE_REMOTE_URI: 270 if (!strlen($old)) { 271 return pht( 272 '%s set the remote URI for this repository to "%s".', 273 $this->renderHandleLink($author_phid), 274 $new); 275 } else if (!strlen($new)) { 276 return pht( 277 '%s removed the remote URI for this repository.', 278 $this->renderHandleLink($author_phid)); 279 } else { 280 return pht( 281 '%s changed the remote URI for this repository from "%s" to "%s".', 282 $this->renderHandleLink($author_phid), 283 $old, 284 $new); 285 } 286 break; 287 case self::TYPE_SSH_LOGIN: 288 return pht( 289 '%s updated the SSH login for this repository.', 290 $this->renderHandleLink($author_phid)); 291 case self::TYPE_SSH_KEY: 292 return pht( 293 '%s updated the SSH key for this repository.', 294 $this->renderHandleLink($author_phid)); 295 case self::TYPE_SSH_KEYFILE: 296 return pht( 297 '%s updated the SSH keyfile for this repository.', 298 $this->renderHandleLink($author_phid)); 299 case self::TYPE_HTTP_LOGIN: 300 return pht( 301 '%s updated the HTTP login for this repository.', 302 $this->renderHandleLink($author_phid)); 303 case self::TYPE_HTTP_PASS: 304 return pht( 305 '%s updated the HTTP password for this repository.', 306 $this->renderHandleLink($author_phid)); 307 case self::TYPE_LOCAL_PATH: 308 return pht( 309 '%s changed the local path from "%s" to "%s".', 310 $this->renderHandleLink($author_phid), 311 $old, 312 $new); 313 case self::TYPE_HOSTING: 314 if ($new) { 315 return pht( 316 '%s changed this repository to be hosted on Phabricator.', 317 $this->renderHandleLink($author_phid)); 318 } else { 319 return pht( 320 '%s changed this repository to track a remote elsewhere.', 321 $this->renderHandleLink($author_phid)); 322 } 323 case self::TYPE_PROTOCOL_HTTP: 324 return pht( 325 '%s changed the availability of this repository over HTTP from '. 326 '"%s" to "%s".', 327 $this->renderHandleLink($author_phid), 328 PhabricatorRepository::getProtocolAvailabilityName($old), 329 PhabricatorRepository::getProtocolAvailabilityName($new)); 330 case self::TYPE_PROTOCOL_SSH: 331 return pht( 332 '%s changed the availability of this repository over SSH from '. 333 '"%s" to "%s".', 334 $this->renderHandleLink($author_phid), 335 PhabricatorRepository::getProtocolAvailabilityName($old), 336 PhabricatorRepository::getProtocolAvailabilityName($new)); 337 case self::TYPE_PUSH_POLICY: 338 return pht( 339 '%s changed the push policy of this repository from "%s" to "%s".', 340 $this->renderHandleLink($author_phid), 341 $this->renderPolicyName($old, 'old'), 342 $this->renderPolicyName($new, 'new')); 343 case self::TYPE_DANGEROUS: 344 if ($new) { 345 return pht( 346 '%s disabled protection against dangerous changes.', 347 $this->renderHandleLink($author_phid)); 348 } else { 349 return pht( 350 '%s enabled protection against dangerous changes.', 351 $this->renderHandleLink($author_phid)); 352 } 353 case self::TYPE_CLONE_NAME: 354 if (strlen($old) && !strlen($new)) { 355 return pht( 356 '%s removed the clone name of this repository.', 357 $this->renderHandleLink($author_phid)); 358 } else if (strlen($new) && !strlen($old)) { 359 return pht( 360 '%s set the clone name of this repository to "%s".', 361 $this->renderHandleLink($author_phid), 362 $new); 363 } else { 364 return pht( 365 '%s changed the clone name of this repository from "%s" to "%s".', 366 $this->renderHandleLink($author_phid), 367 $old, 368 $new); 369 } 370 } 371 372 return parent::getTitle(); 373 } 374 375 public function hasChangeDetails() { 376 switch ($this->getTransactionType()) { 377 case self::TYPE_DESCRIPTION: 378 return true; 379 } 380 return parent::hasChangeDetails(); 381 } 382 383 public function renderChangeDetails(PhabricatorUser $viewer) { 384 return $this->renderTextCorpusChangeDetails( 385 $viewer, 386 $this->getOldValue(), 387 $this->getNewValue()); 388 } 389 390 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |