diff --git a/.gitignore b/.gitignore index 041179d3..04fbdaa4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ output/ composer.phar build/ cache/ -deploy_docs.sh \ No newline at end of file +deploy_docs.sh diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 123cd84d..fb8fe01e 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,38 +1,34 @@ before_commands: - - git --version - - git config --global user.email "git-elephant@scrutinizer-ci.com" - - git config --global user.name "git-elephant" - - composer install + - git --version + - git config --global user.email "git-elephant@scrutinizer-ci.com" + - git config --global user.name "git-elephant" + - composer install filter: excluded_paths: - 'vendor/*' tools: - php_code_coverage: - enabled: true - filter: - paths: [ src/* ] - excluded_paths: [ tests/*, graphics/*, vendor/* ] - test_command: ./vendor/bin/phpunit - php_code_sniffer: - enabled: true - filter: - paths: [ src/ ] - config: - # Built-in standards: PEAR, PHPCS, PSR1, PSR2, Squiz, Zend - standard: PSR2 - php_cpd: - enabled: true - php_cs_fixer: - enabled: true - config: - level: psr2 - filter: - paths: [ src/ ] - php_mess_detector: - enabled: true - filter: - paths: [ src/ ] - php_analyzer: true - sensiolabs_security_checker: true - php_pdepend: true - php_loc: true \ No newline at end of file + external_code_coverage: + timeout: 600 + php_code_sniffer: + enabled: true + filter: + paths: [ src/ ] + config: + # Built-in standards: PEAR, PHPCS, PSR1, PSR2, Squiz, Zend + standard: PSR2 + php_cpd: + enabled: true + php_cs_fixer: + enabled: true + config: + level: psr2 + filter: + paths: [ src/ ] + php_mess_detector: + enabled: true + filter: + paths: [ src/ ] + php_analyzer: true + sensiolabs_security_checker: true + php_pdepend: true + php_loc: true diff --git a/.travis.yml b/.travis.yml index ef7a7aac..bb8b8067 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,23 @@ language: php php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - hhvm - -matrix: - allow_failures: + - 5.3 + - 5.4 + - 5.5 + - 5.6 - hhvm -branches: - only: - - master - - develop - before_script: - - curl -s https://getcomposer.org/installer | php - - $(which php) composer.phar --dev install - - git --version - - git config --global user.email "test@travis-ci.org" - - git config --global user.name "Travis" - - git --version + - curl -s https://getcomposer.org/installer | php + - $(which php) composer.phar --dev install + - git --version + - git config --global user.email "test@travis-ci.org" + - git config --global user.name "Travis" + - git --version script: - - vendor/bin/phpunit - + - vendor/bin/phpunit --coverage-clover=coverage.clover + +after_success: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover coverage.clover diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..daa972ac --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM php + +RUN apt-get update && apt-get install -qqy git && rm -r /var/lib/apt/lists/* +RUN git config --global user.email "gitelephant@cypresslab.net" +RUN git config --global user.name "gitelephant" + +RUN docker-php-ext-install mbstring +RUN pecl install xdebug +RUN echo "zend_extension = `php-config --extension-dir`/xdebug.so" >> /usr/local/etc/php/php.ini + +WORKDIR /app \ No newline at end of file diff --git a/README.md b/README.md index f787ea2c..23ddb2a8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Latest Stable Version](https://poser.pugx.org/cypresslab/GitElephant/v/stable.png)](https://packagist.org/packages/cypresslab/GitElephant) [![License](https://poser.pugx.org/cypresslab/gitelephant/license.png)](https://packagist.org/packages/cypresslab/gitelephant) [![Total Downloads](https://poser.pugx.org/cypresslab/GitElephant/downloads.png)](https://packagist.org/packages/cypresslab/GitElephant) [![Montly Downloads](https://poser.pugx.org/cypresslab/gitelephant/d/monthly.png)](https://packagist.org/packages/cypresslab/gitelephant) -[![Build Status](https://travis-ci.org/matteosister/GitElephant.png?branch=master)](https://travis-ci.org/matteosister/GitElephant) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/matteosister/GitElephant/badges/quality-score.png?s=c7ca8a7c5ea9c64b291f6bcaef27955ed6d8a836)](https://scrutinizer-ci.com/g/matteosister/GitElephant/) [![Code Coverage](https://scrutinizer-ci.com/g/matteosister/GitElephant/badges/coverage.png?s=fd7981a4f57fd639912d1a415e3dd92615ddce51)](https://scrutinizer-ci.com/g/matteosister/GitElephant/) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/d6da541e-d928-4f70-868a-dd0b6426a7b5/mini.png)](https://insight.sensiolabs.com/projects/d6da541e-d928-4f70-868a-dd0b6426a7b5) +[![Build Status](https://travis-ci.org/matteosister/GitElephant.png?branch=master)](https://travis-ci.org/matteosister/GitElephant) [![Dependency Status](https://www.versioneye.com/user/projects/53da38094b3ac86052000019/badge.svg?style=flat)](https://www.versioneye.com/user/projects/53da38094b3ac86052000019) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/matteosister/GitElephant/badges/quality-score.png?s=c7ca8a7c5ea9c64b291f6bcaef27955ed6d8a836)](https://scrutinizer-ci.com/g/matteosister/GitElephant/) [![Code Coverage](https://scrutinizer-ci.com/g/matteosister/GitElephant/badges/coverage.png?s=fd7981a4f57fd639912d1a415e3dd92615ddce51)](https://scrutinizer-ci.com/g/matteosister/GitElephant/) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/d6da541e-d928-4f70-868a-dd0b6426a7b5/mini.png)](https://insight.sensiolabs.com/projects/d6da541e-d928-4f70-868a-dd0b6426a7b5) GitElephant is an abstraction layer to manage your git repositories with php diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..d19b127e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,4 @@ +php: + build: . + volumes: + - ".:/app" \ No newline at end of file diff --git a/docker-test b/docker-test deleted file mode 100755 index 1fa313b5..00000000 --- a/docker-test +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# assume composer install already done and autoload.php presents... -docker run -v $PWD:/tests git-1.9.2 -docker run -v $PWD:/tests git-1.8.5.3 - diff --git a/docker/1.8.5.3 b/docker/1.8.5.3 deleted file mode 100644 index 53997f8c..00000000 --- a/docker/1.8.5.3 +++ /dev/null @@ -1,34 +0,0 @@ -# GitElephant tests -# -# VERSION 0.1.0 - -FROM ubuntu:14.04 - -MAINTAINER Matteo Giachino matteog@gmail.com - -ENV GITVERSION 1.8.5.3 - -# apt packages -RUN apt-get update -RUN apt-get install -y php5 -RUN apt-get install -y wget -RUN apt-get install -y build-essential - -# git dependencies -RUN apt-get install -y libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev - -# download and build git -RUN wget https://github.com/git/git/archive/v`echo $GITVERSION`.tar.gz -P /git -RUN cd /git && tar -xzf v`echo $GITVERSION`.tar.gz && cd git-`echo $GITVERSION` -RUN cd /git/git-`echo $GITVERSION` && make prefix=/usr/local all -RUN cd /git/git-`echo $GITVERSION` && sudo make prefix=/usr/local install - -# git config -RUN git config --global user.email "docker@docker.it" -RUN git config --global user.name "Docker User" - -# phpunit -ADD https://phar.phpunit.de/phpunit.phar / - -ENTRYPOINT ["/usr/bin/php", "phpunit.phar"] -CMD ["-c", "/tests"] diff --git a/docker/1.9.2 b/docker/1.9.2 deleted file mode 100644 index 7360599f..00000000 --- a/docker/1.9.2 +++ /dev/null @@ -1,34 +0,0 @@ -# GitElephant tests -# -# VERSION 0.1.0 - -FROM ubuntu:14.04 - -MAINTAINER Matteo Giachino matteog@gmail.com - -ENV GITVERSION 1.9.2 - -# apt packages -RUN apt-get update -RUN apt-get install -y php5 -RUN apt-get install -y wget -RUN apt-get install -y build-essential - -# git dependencies -RUN apt-get install -y libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev - -# download and build git -RUN wget https://github.com/git/git/archive/v`echo $GITVERSION`.tar.gz -P /git -RUN cd /git && tar -xzf v`echo $GITVERSION`.tar.gz && cd git-`echo $GITVERSION` -RUN cd /git/git-`echo $GITVERSION` && make prefix=/usr/local all -RUN cd /git/git-`echo $GITVERSION` && sudo make prefix=/usr/local install - -# git config -RUN git config --global user.email "docker@docker.it" -RUN git config --global user.name "Docker User" - -# phpunit -ADD https://phar.phpunit.de/phpunit.phar / - -ENTRYPOINT ["/usr/bin/php", "phpunit.phar"] -CMD ["-c", "/tests"] diff --git a/docker/setup b/docker/setup deleted file mode 100755 index 313a8b9f..00000000 --- a/docker/setup +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -sudo docker build -t git-1.9.2 - < 1.9.2 -sudo docker build -t git-1.8.5.3 - < 1.8.5.3 diff --git a/src/GitElephant/Command/BaseCommand.php b/src/GitElephant/Command/BaseCommand.php index 206ad6ad..df6a0709 100644 --- a/src/GitElephant/Command/BaseCommand.php +++ b/src/GitElephant/Command/BaseCommand.php @@ -21,7 +21,6 @@ use \GitElephant\Repository; use \PhpCollection\Map; -use \PhpCollection\Sequence; /** * BaseCommand diff --git a/src/GitElephant/Command/Caller/Caller.php b/src/GitElephant/Command/Caller/Caller.php index bff49c40..e2eed0a2 100644 --- a/src/GitElephant/Command/Caller/Caller.php +++ b/src/GitElephant/Command/Caller/Caller.php @@ -106,7 +106,7 @@ public function execute($cmd, $git = true, $cwd = null, $acceptedExitCodes = arr $cmd = $this->binary->getPath() . ' ' . $cmd; } - $process = new Process($cmd, $cwd == null ? $this->repositoryPath : $cwd); + $process = new Process($cmd, is_null($cwd) ? $this->repositoryPath : $cwd); $process->setTimeout(15000); $process->run(); if (!in_array($process->getExitCode(), $acceptedExitCodes)) { diff --git a/src/GitElephant/Command/DiffCommand.php b/src/GitElephant/Command/DiffCommand.php index 074006ee..f08934c2 100644 --- a/src/GitElephant/Command/DiffCommand.php +++ b/src/GitElephant/Command/DiffCommand.php @@ -69,13 +69,13 @@ public function diff($of, $with = null, $path = null) $subject = ''; - if ($with == null) { + if (is_null($with)) { $subject .= $of.'^..'.$of; } else { $subject .= $with.'..'.$of; } - if ($path != null) { + if (! is_null($path)) { if (!is_string($path)) { /** @var Object $path */ $path = $path->getPath(); diff --git a/src/GitElephant/Command/LsTreeCommand.php b/src/GitElephant/Command/LsTreeCommand.php index 1ced5c45..6f802f31 100644 --- a/src/GitElephant/Command/LsTreeCommand.php +++ b/src/GitElephant/Command/LsTreeCommand.php @@ -110,7 +110,7 @@ public function tree($ref = 'HEAD', $path = null) */ public function listAll($ref = null) { - if ($ref == null) { + if (is_null($ref)) { $ref = 'HEAD'; } $this->clearAll(); diff --git a/src/GitElephant/Command/MainCommand.php b/src/GitElephant/Command/MainCommand.php index fc96d0f8..7e89e27b 100644 --- a/src/GitElephant/Command/MainCommand.php +++ b/src/GitElephant/Command/MainCommand.php @@ -141,7 +141,7 @@ public function unstage($what) public function commit($message, $stageAll = false, $author = null, $allowEmpty = false) { $this->clearAll(); - if (trim($message) == '' || $message == null) { + if (trim($message) === '' || is_null($message)) { throw new \InvalidArgumentException(sprintf('You can\'t commit without message')); } $this->addCommandName(self::GIT_COMMIT); diff --git a/src/GitElephant/Command/RevParseCommand.php b/src/GitElephant/Command/RevParseCommand.php index d238bed2..af056925 100644 --- a/src/GitElephant/Command/RevParseCommand.php +++ b/src/GitElephant/Command/RevParseCommand.php @@ -20,7 +20,6 @@ namespace GitElephant\Command; use \GitElephant\Objects\Branch; -use \GitElephant\Objects\Remote; use \GitElephant\Repository; /** diff --git a/src/GitElephant/Command/SubCommandCommand.php b/src/GitElephant/Command/SubCommandCommand.php index 02c88a78..2d28d6b2 100644 --- a/src/GitElephant/Command/SubCommandCommand.php +++ b/src/GitElephant/Command/SubCommandCommand.php @@ -96,7 +96,7 @@ public function getCommand() { $command = $this->getCommandName(); - if ($command == null) { + if (is_null($command)) { throw new \RuntimeException("commandName must be specified to build a subcommand"); } diff --git a/src/GitElephant/Command/SubmoduleCommand.php b/src/GitElephant/Command/SubmoduleCommand.php index 3e719708..66963bfc 100644 --- a/src/GitElephant/Command/SubmoduleCommand.php +++ b/src/GitElephant/Command/SubmoduleCommand.php @@ -132,7 +132,7 @@ public function update($recursive = false, $init = false, $force = false, $path if ($recursive === true) { $this->addCommandArgument(self::SUBMODULE_OPTION_RECURSIVE); } - if ($init == true) { + if ($init === true) { $this->addCommandArgument(self::SUBMODULE_OPTION_INIT); } if ($force === true) { diff --git a/src/GitElephant/Command/TagCommand.php b/src/GitElephant/Command/TagCommand.php index d1a0da6d..67bf23ea 100644 --- a/src/GitElephant/Command/TagCommand.php +++ b/src/GitElephant/Command/TagCommand.php @@ -56,7 +56,7 @@ public function create($name, $startPoint = null, $message = null) { $this->clearAll(); $this->addCommandName(self::TAG_COMMAND); - if (null != $message) { + if (null !== $message) { $this->addCommandArgument('-m'); $this->addCommandArgument($message); } diff --git a/src/GitElephant/GitBinary.php b/src/GitElephant/GitBinary.php index a8e05657..a6936f3e 100644 --- a/src/GitElephant/GitBinary.php +++ b/src/GitElephant/GitBinary.php @@ -41,7 +41,7 @@ class GitBinary */ public function __construct($path = null) { - if (null == $path) { + if (is_null($path)) { // unix only! $path = exec('which git'); } diff --git a/src/GitElephant/Objects/Object.php b/src/GitElephant/Objects/Object.php index 1047cd56..81b3c0e2 100644 --- a/src/GitElephant/Objects/Object.php +++ b/src/GitElephant/Objects/Object.php @@ -202,7 +202,7 @@ public function getMimeType($basePath) public function getExtension() { $pos = strrpos($this->name, '.'); - if ($pos == false) { + if ($pos === false) { return null; } else { return substr($this->name, $pos+1); diff --git a/src/GitElephant/Repository.php b/src/GitElephant/Repository.php index 5337dd4a..f026ceb6 100644 --- a/src/GitElephant/Repository.php +++ b/src/GitElephant/Repository.php @@ -117,7 +117,7 @@ class Repository */ public function __construct($repositoryPath, GitBinary $binary = null, $name = null) { - if ($binary == null) { + if (is_null($binary)) { $binary = new GitBinary(); } @@ -282,7 +282,7 @@ public function remove($path, $recursive = false, $force = false) public function commit($message, $stageAll = false, $ref = null, $author = null, $allowEmpty = false) { $currentBranch = null; - if ($ref != null) { + if (! is_null($ref)) { $currentBranch = $this->getMainBranch(); $this->checkout($ref); } @@ -290,7 +290,7 @@ public function commit($message, $stageAll = false, $ref = null, $author = null, $this->stage(); } $this->caller->execute(MainCommand::getInstance($this)->commit($message, $stageAll, $author, $allowEmpty)); - if ($ref != null) { + if (! is_null($ref)) { $this->checkout($currentBranch); } diff --git a/tests/GitElephant/Command/BaseCommandTest.php b/tests/GitElephant/Command/BaseCommandTest.php index d2f7de81..69816797 100644 --- a/tests/GitElephant/Command/BaseCommandTest.php +++ b/tests/GitElephant/Command/BaseCommandTest.php @@ -23,7 +23,7 @@ class BaseCommandTest extends TestCase /** * test class constructor * - * @covers BaseCommand::__construct + * @covers GitElephant\Command\BaseCommand::__construct */ public function testConstructor() { @@ -59,7 +59,7 @@ public function testConstructor() /** * test static factory * - * @covers BaseCommand::getInstance + * @covers GitElephant\Command\BaseCommand::getInstance */ public function testGetInstance() { diff --git a/tests/GitElephant/Objects/ObjectTest.php b/tests/GitElephant/Objects/ObjectTest.php index 4f4596d8..7796e982 100644 --- a/tests/GitElephant/Objects/ObjectTest.php +++ b/tests/GitElephant/Objects/ObjectTest.php @@ -63,8 +63,8 @@ public function testRevParse() /** * test repository getter and setter * - * @covers Object::getRepository - * @covers Object::setRepository + * @covers GitElephant\Objects\Object::getRepository + * @covers GitElephant\Objects\Object::setRepository */ public function testGetSetRepository() { diff --git a/tests/GitElephant/RepositoryTest.php b/tests/GitElephant/RepositoryTest.php index 12914f21..b3ec73d1 100644 --- a/tests/GitElephant/RepositoryTest.php +++ b/tests/GitElephant/RepositoryTest.php @@ -858,9 +858,9 @@ public function testIsBare() /** * test add, remove and get global configs * - * @covers Repository::addGlobalConfig - * @covers Repository::getGlobalConfigs - * @covers Repository::removeGlobalConfig + * @covers GitElephant\Repository::addGlobalConfig + * @covers GitElephant\Repository::getGlobalConfigs + * @covers GitElephant\Repository::removeGlobalConfig */ public function testGlobalConfigs() { @@ -887,9 +887,9 @@ public function testGlobalConfigs() /** * test add, remove and get global options * - * @covers Repository::addGlobalOption - * @covers Repository::getGlobalOptions - * @covers Repository::removeGlobalOption + * @covers GitElephant\Repository::addGlobalOption + * @covers GitElephant\Repository::getGlobalOptions + * @covers GitElephant\Repository::removeGlobalOption */ public function testGlobalOptions() { @@ -916,9 +916,9 @@ public function testGlobalOptions() /** * test add, remove and get global command arguments * - * @covers Repository::addGlobalCommandArgument - * @covers Repository::getGlobalCommandArguments - * @covers Repository::removeGlobalCommandArgument + * @covers GitElephant\Repository::addGlobalCommandArgument + * @covers GitElephant\Repository::getGlobalCommandArguments + * @covers GitElephant\Repository::removeGlobalCommandArgument */ public function testGlobalCommandArguments() {