mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
add "update" mode to Diffusion coverage Conduit
Summary: This diff adds a new mode argument to the Diffusion Conduit API with two options: - "overwrite": the default, maintains the current behavior of deleting all coverage in the specified branch before uploading the new coverage - "update": does not delete old coverage, but will overwrite previous coverage information if it's for the same file and commit `DiffusionRequest::loadCoverage` already loads a file's coverage from the latest available commit, so uploading coverage for different files in different commits with "update" will result in seeing the latest uploaded coverage in Diffusion. Test Plan: manual local verification Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D14428
This commit is contained in:
parent
7fd6704fb5
commit
c589af51e8
3 changed files with 36 additions and 6 deletions
|
@ -0,0 +1,8 @@
|
||||||
|
USE {$NAMESPACE}_repository;
|
||||||
|
DELETE x FROM repository_coverage x
|
||||||
|
LEFT JOIN repository_coverage y
|
||||||
|
ON x.branchID = y.branchID
|
||||||
|
AND x.commitID = y.commitID
|
||||||
|
AND x.pathID = y.pathID
|
||||||
|
AND y.id > x.id
|
||||||
|
WHERE y.id IS NOT NULL;
|
|
@ -20,11 +20,17 @@ final class DiffusionUpdateCoverageConduitAPIMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function defineParamTypes() {
|
protected function defineParamTypes() {
|
||||||
|
$modes = array(
|
||||||
|
'overwrite',
|
||||||
|
'update',
|
||||||
|
);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'repositoryPHID' => 'required phid',
|
'repositoryPHID' => 'required phid',
|
||||||
'branch' => 'required string',
|
'branch' => 'required string',
|
||||||
'commit' => 'required string',
|
'commit' => 'required string',
|
||||||
'coverage' => 'required map<string, string>',
|
'coverage' => 'required map<string, string>',
|
||||||
|
'mode' => 'optional '.$this->formatStringConstants($modes),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,16 +83,31 @@ final class DiffusionUpdateCoverageConduitAPIMethod
|
||||||
$table_name = 'repository_coverage';
|
$table_name = 'repository_coverage';
|
||||||
|
|
||||||
$conn->openTransaction();
|
$conn->openTransaction();
|
||||||
|
$mode = $request->getValue('mode');
|
||||||
|
switch ($mode) {
|
||||||
|
case '':
|
||||||
|
case 'overwrite':
|
||||||
|
// sets the coverage for the whole branch, deleting all previous
|
||||||
|
// coverage information
|
||||||
queryfx(
|
queryfx(
|
||||||
$conn,
|
$conn,
|
||||||
'DELETE FROM %T WHERE branchID = %d',
|
'DELETE FROM %T WHERE branchID = %d',
|
||||||
$table_name,
|
$table_name,
|
||||||
$branch->getID());
|
$branch->getID());
|
||||||
|
break;
|
||||||
|
case 'update':
|
||||||
|
// sets the coverage for the provided files on the specified commit
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$conn->killTransaction();
|
||||||
|
throw new Exception(pht('Invalid mode "%s".', $mode));
|
||||||
|
}
|
||||||
|
|
||||||
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
|
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
|
||||||
queryfx(
|
queryfx(
|
||||||
$conn,
|
$conn,
|
||||||
'INSERT INTO %T (branchID, pathID, commitID, coverage) VALUES %Q',
|
'INSERT INTO %T (branchID, pathID, commitID, coverage) VALUES %Q'.
|
||||||
|
' ON DUPLICATE KEY UPDATE coverage=VALUES(coverage)',
|
||||||
$table_name,
|
$table_name,
|
||||||
$chunk);
|
$chunk);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ final class PhabricatorRepositorySchemaSpec
|
||||||
),
|
),
|
||||||
'key_path' => array(
|
'key_path' => array(
|
||||||
'columns' => array('branchID', 'pathID', 'commitID'),
|
'columns' => array('branchID', 'pathID', 'commitID'),
|
||||||
|
'unique' => true,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue