1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Allow commits to be marked as 'bad' so they won't be parsed. Useful if you work

at a company where someone deleted the entire repository *cough cough*.
This commit is contained in:
epriestley 2011-03-26 23:52:09 -07:00
parent 1a11297dd6
commit fa8f168bd0
8 changed files with 110 additions and 10 deletions

View file

@ -0,0 +1,44 @@
CREATE DATABASE phabricator_herald;
CREATE TABLE phabricator_herald.herald_action (
id int unsigned not null auto_increment primary key,
ruleID int unsigned not null,
action varchar(255) not null,
target text not null
);
CREATE TABLE phabricator_herald.herald_rule (
id int unsigned not null auto_increment primary key,
name varchar(255) not null,
authorPHID varchar(64) binary not null,
contentType varchar(255) not null,
mustMatchAll bool not null,
configVersion int unsigned not null default '1',
dateCreated int unsigned not null,
dateModified int unsigned not null,
unique key (authorPHID, name)
);
CREATE TABLE phabricator_herald.herald_condition (
id int unsigned not null auto_increment primary key,
ruleID int unsigned not null,
fieldName varchar(255) not null,
fieldCondition varchar(255) not null,
value text not null
);
CREATE TABLE phabricator_herald.herald_transcript (
id int unsigned not null auto_increment primary key,
phid varchar(64) binary not null,
time int unsigned not null,
host varchar(255) not null,
psth varchar(255) not null,
duration float not null,
objectPHID varchar(64) binary not null,
dryRun bool not null,
objectTranscript longblob not null,
ruleTranscripts longblob not null,
conditionTranscripts longblob not null,
applyTranscripts longblob not null,
unique key (phid)
);

View file

@ -30,6 +30,12 @@ class DiffusionCommitController extends DiffusionController {
$repository = $drequest->getRepository();
$commit = $drequest->loadCommit();
if (!$commit) {
// TODO: Make more user-friendly.
throw new Exception('This commit has not parsed yet.');
}
$commit_data = $drequest->loadCommitData();
require_celerity_resource('diffusion-commit-view-css');
@ -70,19 +76,38 @@ class DiffusionCommitController extends DiffusionController {
$count = number_format(count($changes));
$change_panel = new AphrontPanelView();
$change_panel->setHeader("Changes ({$count})");
$change_panel->appendChild($change_table);
$bad_commit = null;
if ($count == 0) {
$bad_commit = queryfx_one(
id(new PhabricatorRepository())->establishConnection('r'),
'SELECT * FROM %T WHERE fullCommitName = %s',
PhabricatorRepository::TABLE_BADCOMMIT,
'r'.$repository->getCallsign().$commit->getCommitIdentifier());
}
$content[] = $change_panel;
if ($bad_commit) {
$error_panel = new AphrontErrorView();
$error_panel->setWidth(AphrontErrorView::WIDTH_WIDE);
$error_panel->setTitle('Bad Commit');
$error_panel->appendChild(
phutil_escape_html($bad_commit['description']));
$content[] = $error_panel;
} else {
$change_panel = new AphrontPanelView();
$change_panel->setHeader("Changes ({$count})");
$change_panel->appendChild($change_table);
$change_list =
'<div style="margin: 2em; color: #666; padding: 1em; background: #eee;">'.
'(list of changes goes here)'.
'</div>';
$content[] = $change_panel;
$content[] = $change_list;
$change_list =
'<div style="margin: 2em; color: #666; padding: 1em;
background: #eee;">'.
'(list of changes goes here)'.
'</div>';
$content[] = $change_list;
}
return $this->buildStandardPageResponse(
$content,

View file

@ -9,10 +9,14 @@
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
phutil_require_module('phabricator', 'applications/diffusion/query/pathchange/base');
phutil_require_module('phabricator', 'applications/diffusion/view/commitchangetable');
phutil_require_module('phabricator', 'applications/repository/storage/repository');
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('DiffusionCommitController.php');

View file

@ -22,6 +22,7 @@ class PhabricatorRepository extends PhabricatorRepositoryDAO {
const TABLE_PATHCHANGE = 'repository_pathchange';
const TABLE_FILESYSTEM = 'repository_filesystem';
const TABLE_SUMMARY = 'repository_summary';
const TABLE_BADCOMMIT = 'repository_badcommit';
protected $phid;
protected $name;

View file

@ -84,4 +84,16 @@ abstract class PhabricatorRepositoryCommitParserWorker
return new SimpleXMLElement($xml);
}
protected function isBadCommit($full_commit_name) {
$repository = new PhabricatorRepository();
$bad_commit = queryfx_one(
$repository->establishConnection('w'),
'SELECT * FROM %T WHERE fullCommitName = %s',
PhabricatorRepository::TABLE_BADCOMMIT,
$full_commit_name);
return (bool)$bad_commit;
}
}

View file

@ -9,6 +9,7 @@
phutil_require_module('phabricator', 'applications/repository/storage/commit');
phutil_require_module('phabricator', 'applications/repository/storage/repository');
phutil_require_module('phabricator', 'infrastructure/daemon/workers/worker');
phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phutil', 'future/exec');
phutil_require_module('phutil', 'parser/uri');

View file

@ -23,6 +23,13 @@ class PhabricatorRepositoryGitCommitChangeParserWorker
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
$full_name = 'r'.$repository->getCallsign().$commit->getCommitIdentifier();
echo "Parsing {$full_name}...\n";
if ($this->isBadCommit($full_name)) {
echo "This commit is marked bad!\n";
return;
}
$local_path = $repository->getDetail('local-path');
list($raw) = execx(

View file

@ -44,7 +44,13 @@ class PhabricatorRepositorySvnCommitChangeParserWorker
$svn_commit = $commit->getCommitIdentifier();
$callsign = $repository->getCallsign();
echo "Parsing r{$callsign}{$svn_commit}...\n";
$full_name = 'r'.$callsign.$svn_commit;
echo "Parsing {$full_name}...\n";
if ($this->isBadCommit($full_name)) {
echo "This commit is marked bad!\n";
return;
}
// Pull the top-level path changes out of "svn log". This is pretty
// straightforward; just parse the XML log.