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 2dd3b1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion 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 All @@ -37,7 +38,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$projectUuid = $input->getArgument('project-uuid');
$api = $this->getApplication()->getApi();
$analysis = $api->analyze($projectUuid, $input->getOption('reference'));
$analysis = $api->analyze($projectUuid, $input->getOption('reference'), $input->getOption('branch'));

$chars = array('-', '\\', '|', '/');
$noAnsiStatus = 'Analysis queued';
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 2dd3b1e

Please sign in to comment.