Skip to content

Commit b6cb1fa

Browse files
committed
Fix certain non empty options having a default null value
1 parent 58952a2 commit b6cb1fa

File tree

6 files changed

+15
-17
lines changed

6 files changed

+15
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Symfony bundle which provides a way to version your application using various ve
6060
handler: git
6161
6262
# The message to use for the VCS commit.
63-
commit_message: null
63+
commit_message: 'Update application version to %s'
6464
6565
# The mode for applying tags to version commits:
6666
# - 'always': automatically add a tag without prompting
@@ -69,7 +69,7 @@ Symfony bundle which provides a way to version your application using various ve
6969
tagging_mode: ask # One of "always"; "never"; "ask"
7070
7171
# The message to use for the VCS tag.
72-
tag_message: null
72+
tag_message: 'Update application version to %s'
7373
7474
# The name used for the VCS commit information,
7575
# set to null to use the default VCS configuration.

src/DependencyInjection/Configuration.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Bizkit\VersioningBundle\DependencyInjection;
66

77
use Bizkit\VersioningBundle\Command\IncrementCommand;
8+
use Bizkit\VersioningBundle\VCS\VCSHandlerInterface;
89
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
910
use Symfony\Component\Config\Definition\ConfigurationInterface;
1011

@@ -67,7 +68,7 @@ public function getConfigTreeBuilder(): TreeBuilder
6768
->scalarNode('commit_message')
6869
->info('The message to use for the VCS commit.')
6970
->cannotBeEmpty()
70-
->defaultNull()
71+
->defaultValue(VCSHandlerInterface::DEFAULT_MESSAGE)
7172
->end()
7273
->enumNode('tagging_mode')
7374
->values(IncrementCommand::TAGGING_MODES)
@@ -78,23 +79,20 @@ public function getConfigTreeBuilder(): TreeBuilder
7879
->scalarNode('tag_message')
7980
->info('The message to use for the VCS tag.')
8081
->cannotBeEmpty()
81-
->defaultNull()
82+
->defaultValue(VCSHandlerInterface::DEFAULT_MESSAGE)
8283
->end()
8384

8485
->scalarNode('name')
8586
->info("The name used for the VCS commit information,\nset to null to use the default VCS configuration.")
86-
->cannotBeEmpty()
8787
->defaultNull()
8888
->end()
8989
->scalarNode('email')
9090
->info("The email used for the VCS commit information,\nset to null to use the default VCS configuration.")
91-
->cannotBeEmpty()
9291
->defaultNull()
9392
->end()
9493

9594
->scalarNode('path_to_executable')
9695
->info("The path to the VCS executable,\nset to null for autodiscovery.")
97-
->cannotBeEmpty()
9896
->defaultNull()
9997
->end()
10098
->end()

src/VCS/GitHandler.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
final class GitHandler implements VCSHandlerInterface
1515
{
16-
private const DEFAULT_MESSAGE = 'Update application version to %s';
17-
1816
/**
1917
* @var string
2018
*/

src/VCS/VCSHandlerInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
interface VCSHandlerInterface
1111
{
12+
public const DEFAULT_MESSAGE = 'Update application version to %s';
13+
1214
public function commit(StyleInterface $io, Version $version): void;
1315

1416
public function tag(StyleInterface $io, Version $version): void;

tests/DependencyInjection/BizkitVersioningExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ public function testParametersAreRegistered(): void
269269
self::assertSame(__DIR__.'/version.yaml', $container->getParameter('bizkit_versioning.file'));
270270

271271
self::assertTrue($container->hasParameter('bizkit_versioning.vcs_commit_message'));
272-
self::assertNull($container->getParameter('bizkit_versioning.vcs_commit_message'));
272+
self::assertSame(VCSHandlerInterface::DEFAULT_MESSAGE, $container->getParameter('bizkit_versioning.vcs_commit_message'));
273273

274274
self::assertTrue($container->hasParameter('bizkit_versioning.vcs_tag_message'));
275-
self::assertNull($container->getParameter('bizkit_versioning.vcs_tag_message'));
275+
self::assertSame(VCSHandlerInterface::DEFAULT_MESSAGE, $container->getParameter('bizkit_versioning.vcs_tag_message'));
276276

277277
self::assertTrue($container->hasParameter('bizkit_versioning.vcs_name'));
278278
self::assertNull($container->getParameter('bizkit_versioning.vcs_name'));

tests/DependencyInjection/ConfigurationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public function testDefaultConfig(): void
2525
'format' => 'yaml',
2626
'vcs' => [
2727
'handler' => 'git',
28-
'commit_message' => null,
28+
'commit_message' => 'Update application version to %s',
2929
'tagging_mode' => 'ask',
30-
'tag_message' => null,
30+
'tag_message' => 'Update application version to %s',
3131
'name' => null,
3232
'email' => null,
3333
'path_to_executable' => null,
@@ -44,9 +44,9 @@ public function testConfigWhenVCSIsTrue(): void
4444
self::assertArrayHasKey('vcs', $config);
4545
self::assertSame([
4646
'handler' => 'git',
47-
'commit_message' => null,
47+
'commit_message' => 'Update application version to %s',
4848
'tagging_mode' => 'ask',
49-
'tag_message' => null,
49+
'tag_message' => 'Update application version to %s',
5050
'name' => null,
5151
'email' => null,
5252
'path_to_executable' => null,
@@ -62,9 +62,9 @@ public function testConfigWhenVCSIsFalse(): void
6262
self::assertArrayHasKey('vcs', $config);
6363
self::assertSame([
6464
'handler' => null,
65-
'commit_message' => null,
65+
'commit_message' => 'Update application version to %s',
6666
'tagging_mode' => 'ask',
67-
'tag_message' => null,
67+
'tag_message' => 'Update application version to %s',
6868
'name' => null,
6969
'email' => null,
7070
'path_to_executable' => null,

0 commit comments

Comments
 (0)