2011-04-04 08:23:36 +02:00
|
|
|
<?php
|
|
|
|
|
2012-03-14 00:21:04 +01:00
|
|
|
final class HeraldCommitAdapter extends HeraldObjectAdapter {
|
2011-04-04 08:23:36 +02:00
|
|
|
|
|
|
|
protected $diff;
|
|
|
|
protected $revision;
|
|
|
|
|
|
|
|
protected $repository;
|
|
|
|
protected $commit;
|
|
|
|
protected $commitData;
|
|
|
|
|
|
|
|
protected $emailPHIDs = array();
|
Allow Herald to trigger audits for users or projects
Summary:
Allows you to write a commit rule that triggers an audit by a user (personal
rules) or a project (global rules).
Mostly this is trying to make auditing more lightweight and accessible in
environments where setting up Owners packages doesn't make sense.
For instance, Disqus wants a rule like "trigger an audit for everything that
didn't have a Differential revision". While not necessarily scalable, this is a
perfectly reasonable rule for a small company, but a lot of work to implement
with Owners (and you'll get a lot of collateral damage if you don't make every
committer a project owner).
Instead, they can create a project called 'Unreviewed Commits' and write a rule
like:
- When: Differential revision does not exist
- Action: Trigger an Audit for project: "Unreviewed Commits"
Then whoever cares can join that project and they'll see those audits in their
queue, and when they approve/raise on commits their actions will affect the
project audit.
Similarly, if I want to look at all commits that match some other rule (say,
XSS) but only want to do it like once a month, I can just set up an audit rule
and go through the queue when I feel like it.
NOTE: This abuses the 'packagePHID' field to also store user and project PHIDs.
Through the magic of handles, this (apparently) works fine for now; I'll do a
big schema patch soon but have several other edits I want to make at the same
time.
Also:
- Adds an "active" fiew for /audit/, eventually this will be like the
Differential "active" view (stuff that is relevant to you right now).
- On commits, highlight triggered audits you are responsible for.
Test Plan: Added personal and global audit triggers to Herald, reparsed some
commits with --herald, got audits. Browsed all audit interfaces to make sure
nothing exploded. Viewed a commit where I was responsible for only some audits.
Performed audits and made sure the triggers I am supposed to be responsible for
updated properly.
Reviewers: btrahan, jungejason
Reviewed By: jungejason
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1690
2012-02-27 18:36:30 +01:00
|
|
|
protected $auditMap = array();
|
2011-04-04 08:23:36 +02:00
|
|
|
|
|
|
|
protected $affectedPaths;
|
|
|
|
protected $affectedRevision;
|
|
|
|
protected $affectedPackages;
|
2012-01-14 08:08:19 +01:00
|
|
|
protected $auditNeededPackages;
|
2011-04-04 08:23:36 +02:00
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
PhabricatorRepository $repository,
|
|
|
|
PhabricatorRepositoryCommit $commit,
|
|
|
|
PhabricatorRepositoryCommitData $commit_data) {
|
|
|
|
|
|
|
|
$this->repository = $repository;
|
|
|
|
$this->commit = $commit;
|
|
|
|
$this->commitData = $commit_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPHID() {
|
|
|
|
return $this->commit->getPHID();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEmailPHIDs() {
|
2011-04-04 23:12:20 +02:00
|
|
|
return array_keys($this->emailPHIDs);
|
2011-04-04 08:23:36 +02:00
|
|
|
}
|
|
|
|
|
Allow Herald to trigger audits for users or projects
Summary:
Allows you to write a commit rule that triggers an audit by a user (personal
rules) or a project (global rules).
Mostly this is trying to make auditing more lightweight and accessible in
environments where setting up Owners packages doesn't make sense.
For instance, Disqus wants a rule like "trigger an audit for everything that
didn't have a Differential revision". While not necessarily scalable, this is a
perfectly reasonable rule for a small company, but a lot of work to implement
with Owners (and you'll get a lot of collateral damage if you don't make every
committer a project owner).
Instead, they can create a project called 'Unreviewed Commits' and write a rule
like:
- When: Differential revision does not exist
- Action: Trigger an Audit for project: "Unreviewed Commits"
Then whoever cares can join that project and they'll see those audits in their
queue, and when they approve/raise on commits their actions will affect the
project audit.
Similarly, if I want to look at all commits that match some other rule (say,
XSS) but only want to do it like once a month, I can just set up an audit rule
and go through the queue when I feel like it.
NOTE: This abuses the 'packagePHID' field to also store user and project PHIDs.
Through the magic of handles, this (apparently) works fine for now; I'll do a
big schema patch soon but have several other edits I want to make at the same
time.
Also:
- Adds an "active" fiew for /audit/, eventually this will be like the
Differential "active" view (stuff that is relevant to you right now).
- On commits, highlight triggered audits you are responsible for.
Test Plan: Added personal and global audit triggers to Herald, reparsed some
commits with --herald, got audits. Browsed all audit interfaces to make sure
nothing exploded. Viewed a commit where I was responsible for only some audits.
Performed audits and made sure the triggers I am supposed to be responsible for
updated properly.
Reviewers: btrahan, jungejason
Reviewed By: jungejason
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1690
2012-02-27 18:36:30 +01:00
|
|
|
public function getAuditMap() {
|
|
|
|
return $this->auditMap;
|
|
|
|
}
|
|
|
|
|
2011-04-04 08:23:36 +02:00
|
|
|
public function getHeraldName() {
|
|
|
|
return
|
|
|
|
'r'.
|
|
|
|
$this->repository->getCallsign().
|
|
|
|
$this->commit->getCommitIdentifier();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHeraldTypeName() {
|
|
|
|
return HeraldContentTypeConfig::CONTENT_TYPE_COMMIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function loadAffectedPaths() {
|
|
|
|
if ($this->affectedPaths === null) {
|
Add Related Commits for Owners
Summary:
For each commit, find the affected packages, and provide a way to
search by package.
Test Plan:
create commits that touch and don't touch two packages, and verify
that they display correctly in all the UI pages.
Reviewers: epriestley, blair, nh, tuomaspelkonen
Reviewed By: epriestley
CC: benmathews, aran, epriestley, btrahan, jungejason, mpodobnik, prithvi
Maniphest Tasks: T83
Differential Revision: 1208
2011-12-14 09:53:25 +01:00
|
|
|
$result = PhabricatorOwnerPathQuery::loadAffectedPaths(
|
2013-05-15 17:12:39 +02:00
|
|
|
$this->repository,
|
|
|
|
$this->commit,
|
|
|
|
PhabricatorUser::getOmnipotentUser());
|
2011-04-04 08:23:36 +02:00
|
|
|
$this->affectedPaths = $result;
|
|
|
|
}
|
|
|
|
return $this->affectedPaths;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function loadAffectedPackages() {
|
|
|
|
if ($this->affectedPackages === null) {
|
|
|
|
$packages = PhabricatorOwnersPackage::loadAffectedPackages(
|
|
|
|
$this->repository,
|
|
|
|
$this->loadAffectedPaths());
|
|
|
|
$this->affectedPackages = $packages;
|
|
|
|
}
|
|
|
|
return $this->affectedPackages;
|
|
|
|
}
|
|
|
|
|
2012-01-14 08:08:19 +01:00
|
|
|
public function loadAuditNeededPackage() {
|
|
|
|
if ($this->auditNeededPackages === null) {
|
Migrate "PhabricatorOwnersPackageCommitRelationship" to "PhabricatorRepositoryAuditRequest"
Summary:
- Move table to Repository, since we have no Owners joins in the application anymore but would like to do a Repository join.
- Rename "packagePHID" to "auditorPHID", since this column may contain package, project, or user PHIDs.
Test Plan:
- Browsed Owners, Audit, and Differential interfaces to the Audit tool.
- Made comments and state changes.
- Ran "reparse.php --herald --owners" on several commits.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, epriestley, nh, vrana
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1787
2012-03-05 22:17:29 +01:00
|
|
|
$status_arr = array(
|
2012-01-14 08:08:19 +01:00
|
|
|
PhabricatorAuditStatusConstants::AUDIT_REQUIRED,
|
Migrate "PhabricatorOwnersPackageCommitRelationship" to "PhabricatorRepositoryAuditRequest"
Summary:
- Move table to Repository, since we have no Owners joins in the application anymore but would like to do a Repository join.
- Rename "packagePHID" to "auditorPHID", since this column may contain package, project, or user PHIDs.
Test Plan:
- Browsed Owners, Audit, and Differential interfaces to the Audit tool.
- Made comments and state changes.
- Ran "reparse.php --herald --owners" on several commits.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, epriestley, nh, vrana
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1787
2012-03-05 22:17:29 +01:00
|
|
|
PhabricatorAuditStatusConstants::CONCERNED,
|
|
|
|
);
|
|
|
|
$requests = id(new PhabricatorRepositoryAuditRequest())
|
2012-01-14 08:08:19 +01:00
|
|
|
->loadAllWhere(
|
|
|
|
"commitPHID = %s AND auditStatus IN (%Ls)",
|
|
|
|
$this->commit->getPHID(),
|
|
|
|
$status_arr);
|
|
|
|
|
Migrate "PhabricatorOwnersPackageCommitRelationship" to "PhabricatorRepositoryAuditRequest"
Summary:
- Move table to Repository, since we have no Owners joins in the application anymore but would like to do a Repository join.
- Rename "packagePHID" to "auditorPHID", since this column may contain package, project, or user PHIDs.
Test Plan:
- Browsed Owners, Audit, and Differential interfaces to the Audit tool.
- Made comments and state changes.
- Ran "reparse.php --herald --owners" on several commits.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, epriestley, nh, vrana
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1787
2012-03-05 22:17:29 +01:00
|
|
|
$packages = mpull($requests, 'getAuditorPHID');
|
2012-01-14 08:08:19 +01:00
|
|
|
$this->auditNeededPackages = $packages;
|
|
|
|
}
|
|
|
|
return $this->auditNeededPackages;
|
|
|
|
}
|
|
|
|
|
2011-04-04 08:23:36 +02:00
|
|
|
public function loadDifferentialRevision() {
|
|
|
|
if ($this->affectedRevision === null) {
|
|
|
|
$this->affectedRevision = false;
|
|
|
|
$data = $this->commitData;
|
|
|
|
$revision_id = $data->getCommitDetail('differential.revisionID');
|
|
|
|
if ($revision_id) {
|
|
|
|
$revision = id(new DifferentialRevision())->load($revision_id);
|
|
|
|
if ($revision) {
|
|
|
|
$revision->loadRelationships();
|
|
|
|
$this->affectedRevision = $revision;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->affectedRevision;
|
|
|
|
}
|
|
|
|
|
2013-01-21 16:46:03 +01:00
|
|
|
private function loadCommitDiff() {
|
|
|
|
$drequest = DiffusionRequest::newFromDictionary(
|
|
|
|
array(
|
2013-05-15 00:32:19 +02:00
|
|
|
'user' => PhabricatorUser::getOmnipotentUser(),
|
2013-01-21 16:46:03 +01:00
|
|
|
'repository' => $this->repository,
|
|
|
|
'commit' => $this->commit->getCommitIdentifier(),
|
|
|
|
));
|
|
|
|
|
2013-05-14 22:53:32 +02:00
|
|
|
$raw = DiffusionQuery::callConduitWithDiffusionRequest(
|
|
|
|
PhabricatorUser::getOmnipotentUser(),
|
2013-05-30 17:05:46 +02:00
|
|
|
$drequest,
|
2013-05-14 22:53:32 +02:00
|
|
|
'diffusion.rawdiffquery',
|
|
|
|
array(
|
|
|
|
'commit' => $this->commit->getCommitIdentifier(),
|
|
|
|
'timeout' => 60 * 60 * 15,
|
|
|
|
'linesOfContext' => 0));
|
2013-01-21 16:46:03 +01:00
|
|
|
|
|
|
|
$parser = new ArcanistDiffParser();
|
|
|
|
$changes = $parser->parseDiff($raw);
|
|
|
|
|
|
|
|
$diff = DifferentialDiff::newFromRawChanges($changes);
|
|
|
|
return $diff;
|
|
|
|
}
|
|
|
|
|
2011-04-04 08:23:36 +02:00
|
|
|
public function getHeraldField($field) {
|
|
|
|
$data = $this->commitData;
|
|
|
|
switch ($field) {
|
|
|
|
case HeraldFieldConfig::FIELD_BODY:
|
|
|
|
return $data->getCommitMessage();
|
|
|
|
case HeraldFieldConfig::FIELD_AUTHOR:
|
|
|
|
return $data->getCommitDetail('authorPHID');
|
|
|
|
case HeraldFieldConfig::FIELD_REVIEWER:
|
|
|
|
return $data->getCommitDetail('reviewerPHID');
|
|
|
|
case HeraldFieldConfig::FIELD_DIFF_FILE:
|
|
|
|
return $this->loadAffectedPaths();
|
|
|
|
case HeraldFieldConfig::FIELD_REPOSITORY:
|
|
|
|
return $this->repository->getPHID();
|
|
|
|
case HeraldFieldConfig::FIELD_DIFF_CONTENT:
|
|
|
|
try {
|
2013-01-21 16:46:03 +01:00
|
|
|
$diff = $this->loadCommitDiff();
|
2011-04-04 08:23:36 +02:00
|
|
|
} catch (Exception $ex) {
|
|
|
|
return array(
|
2013-01-21 16:46:03 +01:00
|
|
|
'<<< Failed to load diff, this may mean the change was '.
|
|
|
|
'unimaginably enormous. >>>');
|
2011-04-04 08:23:36 +02:00
|
|
|
}
|
|
|
|
$dict = array();
|
|
|
|
$lines = array();
|
2013-01-21 16:46:03 +01:00
|
|
|
$changes = $diff->getChangesets();
|
2011-04-04 08:23:36 +02:00
|
|
|
foreach ($changes as $change) {
|
|
|
|
$lines = array();
|
|
|
|
foreach ($change->getHunks() as $hunk) {
|
|
|
|
$lines[] = $hunk->makeChanges();
|
|
|
|
}
|
2013-01-21 16:46:03 +01:00
|
|
|
$dict[$change->getFilename()] = implode("\n", $lines);
|
2011-04-04 08:23:36 +02:00
|
|
|
}
|
|
|
|
return $dict;
|
|
|
|
case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE:
|
|
|
|
$packages = $this->loadAffectedPackages();
|
|
|
|
return mpull($packages, 'getPHID');
|
|
|
|
case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE_OWNER:
|
|
|
|
$packages = $this->loadAffectedPackages();
|
|
|
|
$owners = PhabricatorOwnersOwner::loadAllForPackages($packages);
|
|
|
|
return mpull($owners, 'getUserPHID');
|
2012-01-14 08:08:19 +01:00
|
|
|
case HeraldFieldConfig::FIELD_NEED_AUDIT_FOR_PACKAGE:
|
|
|
|
return $this->loadAuditNeededPackage();
|
2011-04-04 08:23:36 +02:00
|
|
|
case HeraldFieldConfig::FIELD_DIFFERENTIAL_REVISION:
|
|
|
|
$revision = $this->loadDifferentialRevision();
|
|
|
|
if (!$revision) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return $revision->getID();
|
|
|
|
case HeraldFieldConfig::FIELD_DIFFERENTIAL_REVIEWERS:
|
|
|
|
$revision = $this->loadDifferentialRevision();
|
|
|
|
if (!$revision) {
|
2012-06-19 06:07:12 +02:00
|
|
|
return array();
|
2011-04-04 08:23:36 +02:00
|
|
|
}
|
|
|
|
return $revision->getReviewers();
|
|
|
|
case HeraldFieldConfig::FIELD_DIFFERENTIAL_CCS:
|
|
|
|
$revision = $this->loadDifferentialRevision();
|
|
|
|
if (!$revision) {
|
2012-06-19 06:07:12 +02:00
|
|
|
return array();
|
2011-04-04 08:23:36 +02:00
|
|
|
}
|
|
|
|
return $revision->getCCPHIDs();
|
|
|
|
default:
|
|
|
|
throw new Exception("Invalid field '{$field}'.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function applyHeraldEffects(array $effects) {
|
2012-04-03 21:10:45 +02:00
|
|
|
assert_instances_of($effects, 'HeraldEffect');
|
Allow Herald to trigger audits for users or projects
Summary:
Allows you to write a commit rule that triggers an audit by a user (personal
rules) or a project (global rules).
Mostly this is trying to make auditing more lightweight and accessible in
environments where setting up Owners packages doesn't make sense.
For instance, Disqus wants a rule like "trigger an audit for everything that
didn't have a Differential revision". While not necessarily scalable, this is a
perfectly reasonable rule for a small company, but a lot of work to implement
with Owners (and you'll get a lot of collateral damage if you don't make every
committer a project owner).
Instead, they can create a project called 'Unreviewed Commits' and write a rule
like:
- When: Differential revision does not exist
- Action: Trigger an Audit for project: "Unreviewed Commits"
Then whoever cares can join that project and they'll see those audits in their
queue, and when they approve/raise on commits their actions will affect the
project audit.
Similarly, if I want to look at all commits that match some other rule (say,
XSS) but only want to do it like once a month, I can just set up an audit rule
and go through the queue when I feel like it.
NOTE: This abuses the 'packagePHID' field to also store user and project PHIDs.
Through the magic of handles, this (apparently) works fine for now; I'll do a
big schema patch soon but have several other edits I want to make at the same
time.
Also:
- Adds an "active" fiew for /audit/, eventually this will be like the
Differential "active" view (stuff that is relevant to you right now).
- On commits, highlight triggered audits you are responsible for.
Test Plan: Added personal and global audit triggers to Herald, reparsed some
commits with --herald, got audits. Browsed all audit interfaces to make sure
nothing exploded. Viewed a commit where I was responsible for only some audits.
Performed audits and made sure the triggers I am supposed to be responsible for
updated properly.
Reviewers: btrahan, jungejason
Reviewed By: jungejason
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1690
2012-02-27 18:36:30 +01:00
|
|
|
|
2011-04-04 08:23:36 +02:00
|
|
|
$result = array();
|
|
|
|
foreach ($effects as $effect) {
|
|
|
|
$action = $effect->getAction();
|
|
|
|
switch ($action) {
|
|
|
|
case HeraldActionConfig::ACTION_NOTHING:
|
|
|
|
$result[] = new HeraldApplyTranscript(
|
|
|
|
$effect,
|
|
|
|
true,
|
2013-05-20 17:24:07 +02:00
|
|
|
pht('Great success at doing nothing.'));
|
2011-04-04 08:23:36 +02:00
|
|
|
break;
|
|
|
|
case HeraldActionConfig::ACTION_EMAIL:
|
Allow Herald to trigger audits for users or projects
Summary:
Allows you to write a commit rule that triggers an audit by a user (personal
rules) or a project (global rules).
Mostly this is trying to make auditing more lightweight and accessible in
environments where setting up Owners packages doesn't make sense.
For instance, Disqus wants a rule like "trigger an audit for everything that
didn't have a Differential revision". While not necessarily scalable, this is a
perfectly reasonable rule for a small company, but a lot of work to implement
with Owners (and you'll get a lot of collateral damage if you don't make every
committer a project owner).
Instead, they can create a project called 'Unreviewed Commits' and write a rule
like:
- When: Differential revision does not exist
- Action: Trigger an Audit for project: "Unreviewed Commits"
Then whoever cares can join that project and they'll see those audits in their
queue, and when they approve/raise on commits their actions will affect the
project audit.
Similarly, if I want to look at all commits that match some other rule (say,
XSS) but only want to do it like once a month, I can just set up an audit rule
and go through the queue when I feel like it.
NOTE: This abuses the 'packagePHID' field to also store user and project PHIDs.
Through the magic of handles, this (apparently) works fine for now; I'll do a
big schema patch soon but have several other edits I want to make at the same
time.
Also:
- Adds an "active" fiew for /audit/, eventually this will be like the
Differential "active" view (stuff that is relevant to you right now).
- On commits, highlight triggered audits you are responsible for.
Test Plan: Added personal and global audit triggers to Herald, reparsed some
commits with --herald, got audits. Browsed all audit interfaces to make sure
nothing exploded. Viewed a commit where I was responsible for only some audits.
Performed audits and made sure the triggers I am supposed to be responsible for
updated properly.
Reviewers: btrahan, jungejason
Reviewed By: jungejason
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1690
2012-02-27 18:36:30 +01:00
|
|
|
foreach ($effect->getTarget() as $phid) {
|
|
|
|
$this->emailPHIDs[$phid] = true;
|
2011-04-04 08:23:36 +02:00
|
|
|
}
|
|
|
|
$result[] = new HeraldApplyTranscript(
|
|
|
|
$effect,
|
|
|
|
true,
|
2013-05-20 17:24:07 +02:00
|
|
|
pht('Added address to email targets.'));
|
2011-04-04 08:23:36 +02:00
|
|
|
break;
|
Allow Herald to trigger audits for users or projects
Summary:
Allows you to write a commit rule that triggers an audit by a user (personal
rules) or a project (global rules).
Mostly this is trying to make auditing more lightweight and accessible in
environments where setting up Owners packages doesn't make sense.
For instance, Disqus wants a rule like "trigger an audit for everything that
didn't have a Differential revision". While not necessarily scalable, this is a
perfectly reasonable rule for a small company, but a lot of work to implement
with Owners (and you'll get a lot of collateral damage if you don't make every
committer a project owner).
Instead, they can create a project called 'Unreviewed Commits' and write a rule
like:
- When: Differential revision does not exist
- Action: Trigger an Audit for project: "Unreviewed Commits"
Then whoever cares can join that project and they'll see those audits in their
queue, and when they approve/raise on commits their actions will affect the
project audit.
Similarly, if I want to look at all commits that match some other rule (say,
XSS) but only want to do it like once a month, I can just set up an audit rule
and go through the queue when I feel like it.
NOTE: This abuses the 'packagePHID' field to also store user and project PHIDs.
Through the magic of handles, this (apparently) works fine for now; I'll do a
big schema patch soon but have several other edits I want to make at the same
time.
Also:
- Adds an "active" fiew for /audit/, eventually this will be like the
Differential "active" view (stuff that is relevant to you right now).
- On commits, highlight triggered audits you are responsible for.
Test Plan: Added personal and global audit triggers to Herald, reparsed some
commits with --herald, got audits. Browsed all audit interfaces to make sure
nothing exploded. Viewed a commit where I was responsible for only some audits.
Performed audits and made sure the triggers I am supposed to be responsible for
updated properly.
Reviewers: btrahan, jungejason
Reviewed By: jungejason
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1690
2012-02-27 18:36:30 +01:00
|
|
|
case HeraldActionConfig::ACTION_AUDIT:
|
|
|
|
foreach ($effect->getTarget() as $phid) {
|
|
|
|
if (empty($this->auditMap[$phid])) {
|
|
|
|
$this->auditMap[$phid] = array();
|
|
|
|
}
|
|
|
|
$this->auditMap[$phid][] = $effect->getRuleID();
|
|
|
|
}
|
2012-03-30 22:51:54 +02:00
|
|
|
$result[] = new HeraldApplyTranscript(
|
|
|
|
$effect,
|
|
|
|
true,
|
2013-05-20 17:24:07 +02:00
|
|
|
pht('Triggered an audit.'));
|
2012-03-30 22:51:54 +02:00
|
|
|
break;
|
|
|
|
case HeraldActionConfig::ACTION_FLAG:
|
|
|
|
$result[] = parent::applyFlagEffect(
|
|
|
|
$effect,
|
|
|
|
$this->commit->getPHID());
|
Allow Herald to trigger audits for users or projects
Summary:
Allows you to write a commit rule that triggers an audit by a user (personal
rules) or a project (global rules).
Mostly this is trying to make auditing more lightweight and accessible in
environments where setting up Owners packages doesn't make sense.
For instance, Disqus wants a rule like "trigger an audit for everything that
didn't have a Differential revision". While not necessarily scalable, this is a
perfectly reasonable rule for a small company, but a lot of work to implement
with Owners (and you'll get a lot of collateral damage if you don't make every
committer a project owner).
Instead, they can create a project called 'Unreviewed Commits' and write a rule
like:
- When: Differential revision does not exist
- Action: Trigger an Audit for project: "Unreviewed Commits"
Then whoever cares can join that project and they'll see those audits in their
queue, and when they approve/raise on commits their actions will affect the
project audit.
Similarly, if I want to look at all commits that match some other rule (say,
XSS) but only want to do it like once a month, I can just set up an audit rule
and go through the queue when I feel like it.
NOTE: This abuses the 'packagePHID' field to also store user and project PHIDs.
Through the magic of handles, this (apparently) works fine for now; I'll do a
big schema patch soon but have several other edits I want to make at the same
time.
Also:
- Adds an "active" fiew for /audit/, eventually this will be like the
Differential "active" view (stuff that is relevant to you right now).
- On commits, highlight triggered audits you are responsible for.
Test Plan: Added personal and global audit triggers to Herald, reparsed some
commits with --herald, got audits. Browsed all audit interfaces to make sure
nothing exploded. Viewed a commit where I was responsible for only some audits.
Performed audits and made sure the triggers I am supposed to be responsible for
updated properly.
Reviewers: btrahan, jungejason
Reviewed By: jungejason
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1690
2012-02-27 18:36:30 +01:00
|
|
|
break;
|
2011-04-04 08:23:36 +02:00
|
|
|
default:
|
|
|
|
throw new Exception("No rules to handle action '{$action}'.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|