1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-04 04:32:43 +01:00
phorge-phorge/src/applications/diffusion/harbormaster/DiffusionBuildableEngine.php
epriestley 632cafec88 Pass commit authorship information to Buildkite
Summary:
Fixes T12251. Ref T13189. See PHI610. The difficulty here is that we don't want to disclose Phabricator account information to Buildkite. We're comfortable disclosing information from `git`, etc.

  - For commits, use the Identity to provide authorship information from Git.
  - For revisions, use the local commit information on the Diff to provide the Git/Mercurial/etc author of the HEAD commit.

Test Plan:
  - Built commits and revisions in Buildkite via Harbormaster.
  - I can't actually figure out how to see author information on the Buildkite side, but the values look sane when dumped locally.

Reviewers: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13189, T12251

Differential Revision: https://secure.phabricator.com/D19614
2018-08-27 12:52:11 -07:00

43 lines
1.2 KiB
PHP

<?php
final class DiffusionBuildableEngine
extends HarbormasterBuildableEngine {
public function publishBuildable(
HarbormasterBuildable $old,
HarbormasterBuildable $new) {
// Don't publish manual buildables.
if ($new->getIsManualBuildable()) {
return;
}
// Don't publish anything if the buildable status has not changed. At
// least for now, Diffusion handles buildable status exactly the same
// way that Harbormaster does.
$old_status = $old->getBuildableStatus();
$new_status = $new->getBuildableStatus();
if ($old_status === $new_status) {
return;
}
// Don't publish anything if the buildable is still building.
if ($new->isBuilding()) {
return;
}
$xaction = $this->newTransaction()
->setMetadataValue('harbormaster:buildablePHID', $new->getPHID())
->setTransactionType(DiffusionCommitBuildableTransaction::TRANSACTIONTYPE)
->setNewValue($new->getBuildableStatus());
$this->applyTransactions(array($xaction));
}
public function getAuthorIdentity() {
return $this->getObject()
->loadIdentities($this->getViewer())
->getAuthorIdentity();
}
}