File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -111,10 +111,14 @@ public function getConfigTreeBuilder(): TreeBuilder
111
111
->prototype ('scalar ' );
112
112
$ optionsChildNodes ->scalarNode ('project_root ' );
113
113
114
- $ releaseNode = $ optionsChildNodes ->scalarNode ('release ' )
114
+ $ optionsChildNodes ->scalarNode ('release ' )
115
115
->info ('Release version to be reported to sentry, see https://docs.sentry.io/workflow/releases/?platform=php ' )
116
- ->example ('my/application@ff11bb ' );
117
- $ releaseNode ->defaultValue (PrettyVersions::getRootPackageVersion ()->getPrettyVersion ());
116
+ ->example ('my-application@ff11bb ' )
117
+ ->beforeNormalization ()
118
+ ->ifString ()
119
+ ->then ($ this ->escapeInvalidReleaseCharacters ())
120
+ ->end ()
121
+ ->defaultValue (PrettyVersions::getRootPackageVersion ()->getPrettyVersion ());
118
122
119
123
$ optionsChildNodes ->floatNode ('sample_rate ' )
120
124
->min (0.0 )
@@ -177,6 +181,13 @@ public function getConfigTreeBuilder(): TreeBuilder
177
181
return $ treeBuilder ;
178
182
}
179
183
184
+ private function escapeInvalidReleaseCharacters (): \Closure
185
+ {
186
+ return static function ($ str ): string {
187
+ return str_replace ('/ ' , '- ' , $ str );
188
+ };
189
+ }
190
+
180
191
private function getTrimClosure (): \Closure
181
192
{
182
193
return static function ($ str ): ?string {
Original file line number Diff line number Diff line change @@ -137,6 +137,13 @@ public function optionValuesProvider(): array
137
137
];
138
138
}
139
139
140
+ public function testReleaseValueEscaped (): void
141
+ {
142
+ $ processed = $ this ->processConfiguration (['options ' => ['release ' => 'abc/123 ' ]]);
143
+
144
+ $ this ->assertContains (['options ' => ['release ' => 'abc-123 ' ]], $ processed );
145
+ }
146
+
140
147
/**
141
148
* @dataProvider invalidValuesProvider
142
149
*/
You can’t perform that action at this time.
0 commit comments