@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move build variables into HarbormasterBuildableInterface

Summary: Ref T1049. This moves the declaration of build variables onto HarbormasterBuildableInterface, allowing new classes implementing HarbormasterBuildableInterface to declare their own variables.

Test Plan: Implemented it on another class, saw the build variables appear.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T1049

Differential Revision: https://secure.phabricator.com/D9618

+92 -27
+32
src/applications/differential/storage/DifferentialDiff.php
··· 333 333 return null; 334 334 } 335 335 336 + public function getBuildVariables() { 337 + $results = array(); 338 + 339 + $results['buildable.diff'] = $this->getID(); 340 + $revision = $this->getRevision(); 341 + $results['buildable.revision'] = $revision->getID(); 342 + $repo = $revision->getRepository(); 343 + 344 + if ($repo) { 345 + $results['repository.callsign'] = $repo->getCallsign(); 346 + $results['repository.vcs'] = $repo->getVersionControlSystem(); 347 + $results['repository.uri'] = $repo->getPublicCloneURI(); 348 + } 349 + 350 + return $results; 351 + } 352 + 353 + public function getAvailableBuildVariables() { 354 + return array( 355 + 'buildable.diff' => 356 + pht('The differential diff ID, if applicable.'), 357 + 'buildable.revision' => 358 + pht('The differential revision ID, if applicable.'), 359 + 'repository.callsign' => 360 + pht('The callsign of the repository in Phabricator.'), 361 + 'repository.vcs' => 362 + pht('The version control system, either "svn", "hg" or "git".'), 363 + 'repository.uri' => 364 + pht('The URI to clone or checkout the repository from.'), 365 + ); 366 + } 367 + 336 368 337 369 /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 338 370
+8
src/applications/differential/storage/DifferentialRevision.php
··· 361 361 return $this->getPHID(); 362 362 } 363 363 364 + public function getBuildVariables() { 365 + return array(); 366 + } 367 + 368 + public function getAvailableBuildVariables() { 369 + return array(); 370 + } 371 + 364 372 365 373 /* -( PhabricatorSubscribableInterface )----------------------------------- */ 366 374
+4
src/applications/harbormaster/interface/HarbormasterBuildableInterface.php
··· 5 5 public function getHarbormasterBuildablePHID(); 6 6 public function getHarbormasterContainerPHID(); 7 7 8 + public function getBuildVariables(); 9 + 10 + public function getAvailableBuildVariables(); 11 + 8 12 }
+8
src/applications/harbormaster/storage/HarbormasterBuildable.php
··· 250 250 return $this->getContainerPHID(); 251 251 } 252 252 253 + public function getBuildVariables() { 254 + return array(); 255 + } 256 + 257 + public function getAvailableBuildVariables() { 258 + return array(); 259 + } 260 + 253 261 254 262 }
+15 -27
src/applications/harbormaster/storage/build/HarbormasterBuild.php
··· 235 235 $buildable = $this->getBuildable(); 236 236 $object = $buildable->getBuildableObject(); 237 237 238 - $repo = null; 239 - if ($object instanceof DifferentialDiff) { 240 - $results['buildable.diff'] = $object->getID(); 241 - $revision = $object->getRevision(); 242 - $results['buildable.revision'] = $revision->getID(); 243 - $repo = $revision->getRepository(); 244 - } else if ($object instanceof PhabricatorRepositoryCommit) { 245 - $results['buildable.commit'] = $object->getCommitIdentifier(); 246 - $repo = $object->getRepository(); 247 - } 238 + $object_variables = $object->getBuildVariables(); 248 239 249 - if ($repo) { 250 - $results['repository.callsign'] = $repo->getCallsign(); 251 - $results['repository.vcs'] = $repo->getVersionControlSystem(); 252 - $results['repository.uri'] = $repo->getPublicCloneURI(); 253 - } 240 + $results = $object_variables + $results; 254 241 255 242 $results['step.timestamp'] = time(); 256 243 $results['build.id'] = $this->getID(); ··· 259 246 } 260 247 261 248 public static function getAvailableBuildVariables() { 262 - return array( 263 - 'buildable.diff' => 264 - pht('The differential diff ID, if applicable.'), 265 - 'buildable.revision' => 266 - pht('The differential revision ID, if applicable.'), 267 - 'buildable.commit' => pht('The commit identifier, if applicable.'), 268 - 'repository.callsign' => 269 - pht('The callsign of the repository in Phabricator.'), 270 - 'repository.vcs' => 271 - pht('The version control system, either "svn", "hg" or "git".'), 272 - 'repository.uri' => 273 - pht('The URI to clone or checkout the repository from.'), 249 + $objects = id(new PhutilSymbolLoader()) 250 + ->setAncestorClass('HarbormasterBuildableInterface') 251 + ->loadObjects(); 252 + 253 + $variables = array(); 254 + $variables[] = array( 274 255 'step.timestamp' => pht('The current UNIX timestamp.'), 275 256 'build.id' => pht('The ID of the current build.'), 276 257 'target.phid' => pht('The PHID of the current build target.'), 277 258 ); 259 + 260 + foreach ($objects as $object) { 261 + $variables[] = $object->getAvailableBuildVariables(); 262 + } 263 + 264 + $variables = array_mergev($variables); 265 + return $variables; 278 266 } 279 267 280 268 public function isComplete() {
+25
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 282 282 return $this->getRepository()->getPHID(); 283 283 } 284 284 285 + public function getBuildVariables() { 286 + $results = array(); 287 + 288 + $results['buildable.commit'] = $this->getCommitIdentifier(); 289 + $repo = $this->getRepository(); 290 + 291 + $results['repository.callsign'] = $repo->getCallsign(); 292 + $results['repository.vcs'] = $repo->getVersionControlSystem(); 293 + $results['repository.uri'] = $repo->getPublicCloneURI(); 294 + 295 + return $results; 296 + } 297 + 298 + public function getAvailableBuildVariables() { 299 + return array( 300 + 'buildable.commit' => pht('The commit identifier, if applicable.'), 301 + 'repository.callsign' => 302 + pht('The callsign of the repository in Phabricator.'), 303 + 'repository.vcs' => 304 + pht('The version control system, either "svn", "hg" or "git".'), 305 + 'repository.uri' => 306 + pht('The URI to clone or checkout the repository from.'), 307 + ); 308 + } 309 + 285 310 286 311 /* -( PhabricatorCustomFieldInterface )------------------------------------ */ 287 312