Skip to content

Commit

Permalink
Merge pull request #641 from ergebnis/feature/name
Browse files Browse the repository at this point in the history
Enhancement: Show name and author of plugin
  • Loading branch information
ergebnis-bot authored Dec 29, 2020
2 parents ef1f145 + 36d9520 commit 9df7fce
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ For a full diff see [`2.12.0...main`][2.12.0...main].

For a full diff see [`2.11.0...2.12.0`][2.11.0...2.12.0].

### Added

* Started showing plugin and author name when running `composer normalize` ([#641]), by [@localheinz]

### Fixed

* Required `composer/composer:2.0.8` for `composer-normalize.phar` ([#596]), by [@localheinz]
Expand Down Expand Up @@ -620,6 +624,7 @@ For a full diff see [`81bc3a8...0.1.0`][81bc3a8...0.1.0].
[#597]: /~https://github.com/ergebnis/composer-normalize/pull/597
[#608]: /~https://github.com/ergebnis/composer-normalize/pull/608
[#615]: /~https://github.com/ergebnis/composer-normalize/pull/615
[#641]: /~https://github.com/ergebnis/composer-normalize/pull/641

[@core23]: /~https://github.com/core23
[@dependabot]: /~https://github.com/dependabot
Expand Down
38 changes: 36 additions & 2 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,46 @@
*/
final class Application extends Console\Application
{
/**
* @see /~https://github.com/box-project/box/blob/master/doc/configuration.md#pretty-git-tag-placeholder-git
*
* @var string
*/
private $version = '@git@';

public function getLongVersion(): string
{
$attribution = 'by <info>Andreas Möller</info> and contributors';

$version = $this->getVersion();

if ('' === $version) {
return \sprintf(
'<info>%s</info> %s',
$this->getName(),
$attribution
);
}

return \sprintf(
'%s <info>%s</info> with ergebnis/composer-normalize <info>@git@</info>',
'<info>%s</info> %s %s',
$this->getName(),
$this->getVersion()
$version,
$attribution
);
}

public function getName(): string
{
return 'ergebnis/composer-normalize';
}

public function getVersion(): string
{
if ('@' . 'git@' === $this->version) {
return '';
}

return $this->version;
}
}
8 changes: 8 additions & 0 deletions src/Command/NormalizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
{
$io = $this->getIO();

$io->write([
\sprintf(
'Running %s.',
$this->getApplication()->getLongVersion()
),
'',
]);

$indent = null;

try {
Expand Down
7 changes: 1 addition & 6 deletions test/Unit/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ final class ApplicationTest extends Framework\TestCase
{
public function testGetLongVersionReturnsVersion(): void
{
$composerApplication = new \Composer\Console\Application();
$application = new Application();

$expected = \sprintf(
'%s <info>%s</info> with ergebnis/composer-normalize <info>@git@</info>',
$composerApplication->getName(),
$composerApplication->getVersion()
);
$expected = '<info>ergebnis/composer-normalize</info> by <info>Andreas Möller</info> and contributors';

self::assertSame($expected, $application->getLongVersion());
}
Expand Down

0 comments on commit 9df7fce

Please sign in to comment.