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

Add a branch option on "analyze" command #78

Merged
merged 1 commit into from
Apr 4, 2019
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- php: 7.0
- php: 7.1
- php: 7.2
- php: hhvm
- php: 7.3
- stage: release
php: 5.3
dist: precise
Expand Down
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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it have a -b shortcut ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not, I would like to be coherent with other options not having one. You can create a PR to add a shortcut on all option if you want, I'd be happy to merge it :) !

->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