Skip to content

Commit

Permalink
Merge pull request #158 from cpliakas/bump-deps
Browse files Browse the repository at this point in the history
Bump dependencies, code styling and static analysis fixes
  • Loading branch information
TomasVotruba committed Jul 18, 2018
2 parents 0ea6f3c + 6f3f99b commit e60ffc7
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 29 deletions.
47 changes: 46 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
# Changelog

## [v2.0.0]
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

PRs and issues are linked, so you can find more about it. Thanks to [ChangelogLinker](https://github.com/Symplify/ChangelogLinker).

<!-- changelog-linker -->

## Unreleased

### Fixed

- [#156] Fix a bug on windows, Thanks to [@wi1dcard]

### Unknown Category

- [#151] PHPUnit 7, Thanks to [@carusogabriel]

## [v2.0.1] - 2018-01-30

### Added

- [#146] Add a test with lowest dependencies, Thanks to [@Soullivaneuh]

### Changed

- [#144] Symfony 4 compatibility improvement., Thanks to [@allansun]
- [#139] Refactoring tests, Thanks to [@carusogabriel]
- [#140] Use Symplify preset config file, Thanks to [@carusogabriel]
- [#142] Pass the previous exception on git exception, Thanks to [@Soullivaneuh]
- [#150] Do not override Process::run, Thanks to [@Soullivaneuh]

## [v2.0.0] - 2017-12-31

### Added

Expand Down Expand Up @@ -93,3 +125,16 @@
[@cpliakas]: https://github.com/cpliakas
[@carusogabriel]: https://github.com/carusogabriel
[@TomasVotruba]: https://github.com/TomasVotruba

[#156]: https://github.com/cpliakas/git-wrapper/pull/156
[#155]: https://github.com/cpliakas/git-wrapper/pull/155
[#151]: https://github.com/cpliakas/git-wrapper/pull/151
[#150]: https://github.com/cpliakas/git-wrapper/pull/150
[#146]: https://github.com/cpliakas/git-wrapper/pull/146
[#144]: https://github.com/cpliakas/git-wrapper/pull/144
[#142]: https://github.com/cpliakas/git-wrapper/pull/142
[#140]: https://github.com/cpliakas/git-wrapper/pull/140
[#139]: https://github.com/cpliakas/git-wrapper/pull/139
[@wi1dcard]: https://github.com/wi1dcard
[@allansun]: https://github.com/allansun
[@Soullivaneuh]: https://github.com/Soullivaneuh
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,16 @@ $options = [
Use the logger listener with [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) compatible loggers such as [Monolog](https://github.com/Seldaek/monolog) to log commands that are executed.

```php
use GitWrapper\Event\GitLoggerListener;
use GitWrapper\Event\GitLoggerEventSubscriber;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

// Log to a file named "git.log"
$log = new Logger('git');
$log->pushHandler(new StreamHandler('git.log', Logger::DEBUG));

// Instantiate the listener, add the logger to it, and register it.
$listener = new GitLoggerListener($log);
$wrapper->addLoggerListener($listener);
// Instantiate the subscriber, add the logger to it, and register it.
$wrapper->addLoggerEventSubscriber(new GitLoggerEventSubscriber($log));

$git = $wrapper->cloneRepository('git://github.com/cpliakas/git-wrapper.git', '/path/to/working/copy');

Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"phpunit/phpunit": "^7.2",
"symfony/filesystem": "^4.0",
"psr/log": "1.0",
"symplify/easy-coding-standard": "^4.4",
"symplify/easy-coding-standard": "^4.5",
"slam/php-cs-fixer-extensions": "^1.16",
"nette/utils": "^2.5",
"phpstan/phpstan": "^0.9",
"symplify/changelog-linker": "^4.4"
"phpstan/phpstan": "^0.10.1",
"symplify/changelog-linker": "^4.5"
},
"autoload": {
"psr-4": {
Expand All @@ -40,6 +40,7 @@
"scripts": {
"check-cs": "vendor/bin/ecs check src tests",
"fix-cs": "vendor/bin/ecs check src tests --fix",
"phpstan": "vendor/bin/phpstan analyse src tests --level max --configuration phpstan.neon"
"phpstan": "vendor/bin/phpstan analyse src tests --level max",
"changelog": "vendor/bin/changelog-linker dump-merges --in-categories"
}
}
2 changes: 1 addition & 1 deletion ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ parameters:
# helper method
- 'src/GitWrapper.php'
# parent interface → nothing we can do about this
- 'src/Event/GitLoggerListener.php'
- 'src/Event/*EventSubscriber.php'

SlamCsFixer\FinalInternalClassFixer:
# class with children
Expand Down
4 changes: 3 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
parameters:
ignoreErrors:
- '#Call to an undefined method GitWrapper\\Event\\GitEvent::getName\(\)#'
- '#Access to an undefined property object::\$data#'
# false positive, is array callable
- '#Parameter \#1 \$function of function call_user_func_array expects callable, array<int, \$this\(GitWrapper\\Test\\GitWorkingCopyTest\)\|int\|string> given#'
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
colors="true"
verbose="true"
>
<testsuite>
<testsuite name="main">
<directory suffix="Test.php">tests</directory>
</testsuite>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psr\Log\LogLevel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

final class GitLoggerListener implements EventSubscriberInterface, LoggerAwareInterface
final class GitLoggerEventSubscriber implements EventSubscriberInterface, LoggerAwareInterface
{
/**
* @var LoggerInterface
Expand Down
2 changes: 1 addition & 1 deletion src/GitBranches.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function fetchBranches(bool $onlyRemote = false): array
{
$options = ($onlyRemote) ? ['r' => true] : ['a' => true];
$output = $this->gitWorkingCopy->branch($options);
$branches = preg_split("/\r\n|\n|\r/", rtrim($output));
$branches = (array) preg_split("/\r\n|\n|\r/", rtrim($output));
return array_map([$this, 'trimBranch'], $branches);
}

Expand Down
2 changes: 1 addition & 1 deletion src/GitTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(GitWorkingCopy $gitWorkingCopy)
public function fetchTags(): array
{
$output = $this->gitWorkingCopy->tag(['l' => true]);
$tags = preg_split("/\r\n|\n|\r/", rtrim($output));
$tags = (array) preg_split("/\r\n|\n|\r/", rtrim($output));
return array_map([$this, 'trimTags'], $tags);
}

Expand Down
6 changes: 3 additions & 3 deletions src/GitWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace GitWrapper;

use GitWrapper\Event\GitEvents;
use GitWrapper\Event\GitLoggerListener;
use GitWrapper\Event\GitLoggerEventSubscriber;
use GitWrapper\Event\GitOutputEvent;
use GitWrapper\Event\GitOutputListenerInterface;
use GitWrapper\Event\GitOutputStreamListener;
Expand Down Expand Up @@ -180,10 +180,10 @@ public function addOutputListener(GitOutputListenerInterface $gitOutputListener)
->addListener(GitEvents::GIT_OUTPUT, [$gitOutputListener, 'handleOutput']);
}

public function addLoggerListener(GitLoggerListener $gitLoggerListener): void
public function addLoggerEventSubscriber(GitLoggerEventSubscriber $gitLoggerEventSubscriber): void
{
$this->getDispatcher()
->addSubscriber($gitLoggerListener);
->addSubscriber($gitLoggerEventSubscriber);
}

public function removeOutputListener(GitOutputListenerInterface $gitOutputListener): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace GitWrapper\Test;

use GitWrapper\Event\GitLoggerListener;
use GitWrapper\Event\GitLoggerEventSubscriber;
use GitWrapper\GitCommand;
use GitWrapper\GitException;
use Psr\Log\LogLevel;
use Psr\Log\NullLogger;
use Throwable;

final class GitLoggerListenerTest extends AbstractGitWrapperTestCase
final class GitLoggerEventSubscriberTest extends AbstractGitWrapperTestCase
{
protected function tearDown(): void
{
Expand All @@ -23,28 +23,28 @@ protected function tearDown(): void
public function testGetLogger(): void
{
$log = new NullLogger();
$listener = new GitLoggerListener($log);
$this->assertSame($log, $listener->getLogger());
$gitLoggerEventSubscriber = new GitLoggerEventSubscriber($log);
$this->assertSame($log, $gitLoggerEventSubscriber->getLogger());
}

public function testSetLogLevelMapping(): void
{
$listener = new GitLoggerListener(new NullLogger());
$listener->setLogLevelMapping('test.event', 'test-level');
$this->assertSame('test-level', $listener->getLogLevelMapping('test.event'));
$gitLoggerEventSubscriber = new GitLoggerEventSubscriber(new NullLogger());
$gitLoggerEventSubscriber->setLogLevelMapping('test.event', 'test-level');
$this->assertSame('test-level', $gitLoggerEventSubscriber->getLogLevelMapping('test.event'));
}

public function testGetInvalidLogLevelMapping(): void
{
$this->expectException(GitException::class);
$listener = new GitLoggerListener(new NullLogger());
$listener->getLogLevelMapping('bad.event');
$gitLoggerEventSubscriber = new GitLoggerEventSubscriber(new NullLogger());
$gitLoggerEventSubscriber->getLogLevelMapping('bad.event');
}

public function testRegisterLogger(): void
{
$logger = new TestLogger();
$this->gitWrapper->addLoggerListener(new GitLoggerListener($logger));
$this->gitWrapper->addLoggerEventSubscriber(new GitLoggerEventSubscriber($logger));
$git = $this->gitWrapper->init(self::REPO_DIR, ['bare' => true]);

$this->assertSame('Git command preparing to run', $logger->messages[0]);
Expand Down Expand Up @@ -78,7 +78,7 @@ public function testRegisterLogger(): void
public function testLogBypassedCommand(): void
{
$logger = new TestLogger();
$this->gitWrapper->addLoggerListener(new GitLoggerListener($logger));
$this->gitWrapper->addLoggerEventSubscriber(new GitLoggerEventSubscriber($logger));

$command = new GitCommand('status', ['s' => true]);
$command->bypass();
Expand Down

0 comments on commit e60ffc7

Please sign in to comment.