Skip to content

Commit e1c945e

Browse files
tareqasnicolas-grekas
authored andcommitted
Get analyses by branch
1 parent 5ad4cd9 commit e1c945e

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ Note: If something went wrong, see *Error management* section
104104

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

107+
// for a specific branch
108+
$api->getAnalyses('project uuid', 'branch name');
109+
107110
### Get an analysis
108111

109112
$api->getAnalysis('project uuid', 'analysis id');

Sdk/Api.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,16 @@ public function createProject(Project $project)
146146
*
147147
* @return Analyses
148148
*/
149-
public function getAnalyses($projectUuid)
149+
public function getAnalyses($projectUuid, $branch = null)
150150
{
151+
$url = sprintf('/api/projects/%s/analyses', $projectUuid);
152+
153+
if ($branch) {
154+
$url .= '?branch='.$branch;
155+
}
156+
151157
return $this->serializer->deserialize(
152-
$this->send('GET', sprintf('/api/projects/%s/analyses', $projectUuid)),
158+
$this->send('GET', $url),
153159
Analyses::class,
154160
'xml'
155161
);

Sdk/Model/Analysis.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ class Analysis
110110
/** @Type("SensioLabs\Insight\Sdk\Model\Violations") */
111111
private $violations;
112112

113+
/**
114+
* @Type("string")
115+
* @SerializedName("branch")
116+
*/
117+
private $branch;
118+
119+
/**
120+
* @Type("string")
121+
* @SerializedName("reference")
122+
*/
123+
private $reference;
124+
113125
/**
114126
* @return Link[]
115127
*/

Sdk/Tests/fixtures/analyses.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<remediation-cost>181.75</remediation-cost>
2727
<remediation-cost-for-next-grade>55.5</remediation-cost-for-next-grade>
2828
<nb-violations>250</nb-violations>
29+
<reference><![CDATA[61dfbb5aab6ad35b25baeab9fc66d35aafc28531]]></reference>
30+
<branch><![CDATA[main]]></branch>
2931
</analysis>
3032
<analysis>
3133
<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"/>
@@ -62,5 +64,7 @@ insight:analyze:wax [--feedback="..."] [--artefacts="..."] [--measure="..."] [--
6264
<remediation-cost>0</remediation-cost>
6365
<remediation-cost-for-next-grade>0</remediation-cost-for-next-grade>
6466
<nb-violations>0</nb-violations>
67+
<reference><![CDATA[61dfbb5aab6ad35b25baeab9fc66d35aafc28673]]></reference>
68+
<branch><![CDATA[master]]></branch>
6569
</analysis>
6670
</analyses>

0 commit comments

Comments
 (0)