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

Enhancement: Show name and author of plugin #641

Merged
merged 1 commit into from
Dec 29, 2020
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
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