Skip to content

Commit

Permalink
Add a branch option on "analyze" command
Browse files Browse the repository at this point in the history
  • Loading branch information
tgalopin committed Apr 4, 2019
1 parent d90c2b3 commit f4f5338
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cli/Command/AnalyzeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protected function configure()
->addArgument('project-uuid', InputArgument::REQUIRED)
->addOption('format', null, InputOption::VALUE_REQUIRED, 'To output in other formats', 'txt')
->addOption('reference', null, InputOption::VALUE_REQUIRED, 'The git reference to analyze')
->addOption('branch', null, InputOption::VALUE_REQUIRED, 'The analysis current branch')
->addOption('show-ignored-violations', null, InputOption::VALUE_NONE, 'Show ignored violations')
->addOption('fail-condition', null, InputOption::VALUE_REQUIRED, '')
->setDescription('Analyze a project')
Expand Down
10 changes: 8 additions & 2 deletions Sdk/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,18 @@ public function getAnalysisStatus($projectUuid, $analysesNumber)
/**
* @param string $projectUuid
* @param string|null $reference A git reference. It can be a commit sha, a tag name or a branch name
* @param string|null $branch Current analysis branch, used by SymfonyInsight to distinguish between the main branch and PRs
*
* @return Analysis
*/
public function analyze($projectUuid, $reference = null)
public function analyze($projectUuid, $reference = null, $branch = null)
{
$request = $this->client->createRequest('POST', sprintf('/api/projects/%s/analyses', $projectUuid), array(), array('reference' => $reference));
$request = $this->client->createRequest(
'POST',
sprintf('/api/projects/%s/analyses', $projectUuid),
array(),
$branch ? array('reference' => $reference, 'branch' => $branch) : array('reference' => $reference)
);

return $this->serializer->deserialize(
(string) $this->send($request)->getBody(),
Expand Down

0 comments on commit f4f5338

Please sign in to comment.