Skip to content

Commit c3de3fa

Browse files
OcramiusJean85
authored andcommitted
#291 defaulting release config to detected root package version (#292)
Effectively automates release tracking for the grand majority of applications out there, without having to resort to to any `VERSION` environment variables nor other custom approaches to be figured out by the end consumer of the library. Ref https://docs.sentry.io/workflow/releases/?platform=php Fixes #291
1 parent ed035b1 commit c3de3fa

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
## Unreleased
88
- Add support for Symfony 5.0 (#266, thanks to @Big-Shark)
99
- Drop support for Symfony < 3.4 (#277)
10+
- Add default value for the `release` option, using the detected root package version (#291 #292, thanks to @Ocramius)
1011

1112
## 3.2.1 (2019-12-19)
1213
- Fix handling of command with no name on `ConsoleListener` (#261)

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"require": {
2222
"php": "^7.1",
2323
"jean85/pretty-package-versions": "^1.0",
24+
"ocramius/package-versions": "^1.3.0",
2425
"sentry/sdk": "^2.0",
2526
"symfony/config": "^3.4||^4.0||^5.0",
2627
"symfony/console": "^3.4||^4.0||^5.0",

src/DependencyInjection/Configuration.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Sentry\SentryBundle\DependencyInjection;
44

55
use Jean85\PrettyVersions;
6+
use PackageVersions\Versions;
67
use Sentry\Options;
78
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
89
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
@@ -114,7 +115,10 @@ public function getConfigTreeBuilder(): TreeBuilder
114115
->prototype('scalar');
115116
$optionsChildNodes->scalarNode('project_root')
116117
->defaultValue('%kernel.project_dir%');
117-
$optionsChildNodes->scalarNode('release');
118+
$optionsChildNodes->scalarNode('release')
119+
->defaultValue(Versions::getVersion(Versions::ROOT_PACKAGE_NAME))
120+
->info('Release version to be reported to sentry, see https://docs.sentry.io/workflow/releases/?platform=php')
121+
->example('my/application@ff11bb');
118122
$optionsChildNodes->floatNode('sample_rate')
119123
->min(0.0)
120124
->max(1.0);

test/DependencyInjection/ConfigurationTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Sentry\SentryBundle\Test\DependencyInjection;
44

55
use Jean85\PrettyVersions;
6+
use PackageVersions\Versions;
67
use Sentry\Options;
78
use Sentry\SentryBundle\DependencyInjection\Configuration;
89
use Sentry\SentryBundle\Test\BaseTestCase;
@@ -66,6 +67,7 @@ public function testConfigurationDefaults(): void
6667
'prefixes' => $defaultSdkValues->getPrefixes(),
6768
'project_root' => '%kernel.project_dir%',
6869
'tags' => [],
70+
'release' => Versions::getVersion('sentry/sentry-symfony'),
6971
],
7072
'monolog' => [
7173
'error_handler' => [

0 commit comments

Comments
 (0)