Skip to content

Commit

Permalink
Get analyses by branch
Browse files Browse the repository at this point in the history
  • Loading branch information
tareqas authored and nicolas-grekas committed Sep 14, 2023
1 parent 5ad4cd9 commit e1c945e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ Note: If something went wrong, see *Error management* section

$api->getAnalyses('project uuid');

// for a specific branch
$api->getAnalyses('project uuid', 'branch name');

### Get an analysis

$api->getAnalysis('project uuid', 'analysis id');
Expand Down
10 changes: 8 additions & 2 deletions Sdk/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,16 @@ public function createProject(Project $project)
*
* @return Analyses
*/
public function getAnalyses($projectUuid)
public function getAnalyses($projectUuid, $branch = null)
{
$url = sprintf('/api/projects/%s/analyses', $projectUuid);

if ($branch) {
$url .= '?branch='.$branch;
}

return $this->serializer->deserialize(
$this->send('GET', sprintf('/api/projects/%s/analyses', $projectUuid)),
$this->send('GET', $url),
Analyses::class,
'xml'
);
Expand Down
12 changes: 12 additions & 0 deletions Sdk/Model/Analysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ class Analysis
/** @Type("SensioLabs\Insight\Sdk\Model\Violations") */
private $violations;

/**
* @Type("string")
* @SerializedName("branch")
*/
private $branch;

/**
* @Type("string")
* @SerializedName("reference")
*/
private $reference;

/**
* @return Link[]
*/
Expand Down
4 changes: 4 additions & 0 deletions Sdk/Tests/fixtures/analyses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<remediation-cost>181.75</remediation-cost>
<remediation-cost-for-next-grade>55.5</remediation-cost-for-next-grade>
<nb-violations>250</nb-violations>
<reference><![CDATA[61dfbb5aab6ad35b25baeab9fc66d35aafc28531]]></reference>
<branch><![CDATA[main]]></branch>
</analysis>
<analysis>
<link href="https://insight.sensiolabs.com/api/projects/fc94cd0a-e079-4489-b2da-1003c045b564/analyses/48?apiToken=b99cb0f2a39a3dc0b42576b5eabd8e093d610d1b5280aea154d90332b23b890c&amp;userUuid=394ccafb-eec3-45ba-93a7-f1d4156b9c80" rel="self" type="application/vnd.com.sensiolabs.insight+xml"/>
Expand Down Expand Up @@ -62,5 +64,7 @@ insight:analyze:wax [--feedback="..."] [--artefacts="..."] [--measure="..."] [--
<remediation-cost>0</remediation-cost>
<remediation-cost-for-next-grade>0</remediation-cost-for-next-grade>
<nb-violations>0</nb-violations>
<reference><![CDATA[61dfbb5aab6ad35b25baeab9fc66d35aafc28673]]></reference>
<branch><![CDATA[master]]></branch>
</analysis>
</analyses>

0 comments on commit e1c945e

Please sign in to comment.