Skip to content

Run api-compare via CLI #15

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

Merged
merged 14 commits into from
Apr 14, 2018
Merged

Conversation

asgrim
Copy link
Member

@asgrim asgrim commented Apr 3, 2018

Prototype here for running via CLI.

Usage currently like:

$ bin/api-compare a:c <from-rev> <to-rev>
$ bin/api-compare a:c 41231369b30957bf89881f02163b51c512c63d6f a1dffda3b9a25d7be501a3d66e50e262c98b511f

Note: this is a VERY rough around the edges initial implementation, and doesn't satisfy all our requirements yet (from #13). For example it doesn't do revision parsing (so it has to be full revision at the moment).

@asgrim
Copy link
Member Author

asgrim commented Apr 3, 2018

Note: some tests are missing, and .travis.yml needs php 7.2 putting in and 7.1 taking out.

@asgrim asgrim self-assigned this Apr 3, 2018
@asgrim asgrim added the WIP label Apr 3, 2018
/** @var Change[] */
private $changes = [];

private function __construct()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of a private constructor in this case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named constructors etc.

{
}

public static function new(): self
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reinventing the wheel i see

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. It does not capture any meaningful value here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two ways to construct this:

  • ::new()
  • ::fromArray()

Fully qualifies having static named constructors here to avoid potential BC breaks in the future

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, That is a valid point and I guess it also follows the "conventions" of the project.


final class ApiCompare extends Command
{
/** @var PerformCheckoutOfRevision */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please expand like the property below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeh the CS will eventually be this (non-expanded)


final class Changes implements IteratorAggregate
{
/** @var Change[] */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please expand

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nm, see above

{
/** @var Change $change */
foreach ($changes as $change) {
$this->output->writeln((string)$change);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some color, be hipster.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea; I'll add an issue but not bothering here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #16

->with(sprintf('[BC] REMOVED: %s', $change1Text));
$output->expects(self::at(1))
->method('writeln')
->with(sprintf(' ADDED: %s', $change2Text));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the extra space?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To line up with [BC]

$fromPath = $this->git->checkout($sourceRepo, Revision::fromSha1($input->getArgument('from')));
$toPath = $this->git->checkout($sourceRepo, Revision::fromSha1($input->getArgument('to')));

// @todo fix hard-coded /src/ addition...
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detect composer-json or psr4 loading?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea - added #17

@asgrim
Copy link
Member Author

asgrim commented Apr 6, 2018

Tests added and passing; no longer WIP and ready for review & merge

@asgrim asgrim added this to the 0.0.1 milestone Apr 14, 2018
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@Ocramius Ocramius merged commit d832068 into master Apr 14, 2018
@Ocramius Ocramius deleted the feature/provide-object-api-for-changes branch April 14, 2018 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants