Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get analyses by branch #104

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading