@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.

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

+36 -6
+8
resources/sql/autopatches/20151109.repository.coverage.1.sql
··· 1 + USE {$NAMESPACE}_repository; 2 + DELETE x FROM repository_coverage x 3 + LEFT JOIN repository_coverage y 4 + ON x.branchID = y.branchID 5 + AND x.commitID = y.commitID 6 + AND x.pathID = y.pathID 7 + AND y.id > x.id 8 + WHERE y.id IS NOT NULL;
+27 -6
src/applications/diffusion/conduit/DiffusionUpdateCoverageConduitAPIMethod.php
··· 20 20 } 21 21 22 22 protected function defineParamTypes() { 23 + $modes = array( 24 + 'overwrite', 25 + 'update', 26 + ); 27 + 23 28 return array( 24 29 'repositoryPHID' => 'required phid', 25 30 'branch' => 'required string', 26 31 'commit' => 'required string', 27 32 'coverage' => 'required map<string, string>', 33 + 'mode' => 'optional '.$this->formatStringConstants($modes), 28 34 ); 29 35 } 30 36 ··· 77 83 $table_name = 'repository_coverage'; 78 84 79 85 $conn->openTransaction(); 80 - queryfx( 81 - $conn, 82 - 'DELETE FROM %T WHERE branchID = %d', 83 - $table_name, 84 - $branch->getID()); 86 + $mode = $request->getValue('mode'); 87 + switch ($mode) { 88 + case '': 89 + case 'overwrite': 90 + // sets the coverage for the whole branch, deleting all previous 91 + // coverage information 92 + queryfx( 93 + $conn, 94 + 'DELETE FROM %T WHERE branchID = %d', 95 + $table_name, 96 + $branch->getID()); 97 + break; 98 + case 'update': 99 + // sets the coverage for the provided files on the specified commit 100 + break; 101 + default: 102 + $conn->killTransaction(); 103 + throw new Exception(pht('Invalid mode "%s".', $mode)); 104 + } 85 105 86 106 foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) { 87 107 queryfx( 88 108 $conn, 89 - 'INSERT INTO %T (branchID, pathID, commitID, coverage) VALUES %Q', 109 + 'INSERT INTO %T (branchID, pathID, commitID, coverage) VALUES %Q'. 110 + ' ON DUPLICATE KEY UPDATE coverage=VALUES(coverage)', 90 111 $table_name, 91 112 $chunk); 92 113 }
+1
src/applications/repository/storage/PhabricatorRepositorySchemaSpec.php
··· 37 37 ), 38 38 'key_path' => array( 39 39 'columns' => array('branchID', 'pathID', 'commitID'), 40 + 'unique' => true, 40 41 ), 41 42 )); 42 43