matteosister / GitElephant

An abstraction layer for git written in PHP
GNU Lesser General Public License v3.0
613 stars 74 forks source link

Support for "git branch --merged" is needed. (solution code included) #51

Closed John-Schlick closed 6 years ago

John-Schlick commented 10 years ago

Since I can't get your unit tests to run, and without that you refuse to take pull requests, here is what it takes to implement "git branch --merged" (which I need in my toolset to determine if a particular branch is merged into another one or not.)

in BranchCommand.php the lists function line adds a merged parameter: move the if all test above the if not simple then below the if not simple change the two --no-color --no-abbrev lines to read: and it becomes: public function lists($all = false, $simple = false, $merged = false) { $this->clearAll(); $this->addCommandName(self::BRANCH_COMMAND); // -a comes before --merged or it fails. if ($all) { $this->addCommandArgument('-a'); } if (!$simple) { $this->addCommandArgument('-v'); } //no-abbrev must come before the merged option. $this->addCommandArgument('--no-abbrev'); // Merged doesn't like --no-color etc, but if not, we want that option. if ($merged) { $this->addCommandArgument('--merged'); } else { $this->addCommandArgument('--no-color'); }

    return $this->getCommand();
}

Then in Repository.php getBranches function line becomes: public function getBranches($namesOnly = false, $all = false, $merged = false)

and the namesonly caller->execute line becomes: $outputLines = $this->caller->execute(BranchCommand::getInstance()->lists($all, true, $merged))->getOutputLines(

and the second one (not namesonly) becomes: $outputLines = $this->caller->execute(BranchCommand::getInstance()->lists($all, false, $merged))->getOutputLines(true);

Pretty simple, it only touches 2 files to make this happen.

matteosister commented 10 years ago

Could you please try to set up the test suite? It's really easy.... your contributions could be really appreciated...

John-Schlick commented 10 years ago

jschlick@dvm-jschlick1:/usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/GitElephant(BGS-1269)$ ls Command GitBinaryTest.php Objects RepositoryTest.php Status TestCase.php UtilitiesTest.php jschlick@dvm-jschlick1:/usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/GitElephant(BGS-1269)$ phpunit RepositoryTest.php PHP Fatal error: Class 'GitElephant\TestCase' not found in /usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/GitElephant/RepositoryTest.php on line 29 PHP Stack trace: PHP 1. {main}() /usr/bin/phpunit:0 PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:584 PHP 3. PHPUnit_TextUI_Command->run() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:132 PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:153 PHP 5. PHPUnit_Runner_BaseTestRunner->loadSuiteClass() phar:///usr/bin/phpunit/phpunit/Runner/BaseTestRunner.php:105 PHP 6. PHPUnit_Runner_StandardTestSuiteLoader->load() phar:///usr/bin/phpunit/phpunit/Runner/BaseTestRunner.php:162 PHP 7. PHPUnit_Util_Fileloader::checkAndLoad() phar:///usr/bin/phpunit/phpunit/Runner/StandardTestSuiteLoader.php:78 PHP 8. PHPUnit_Util_Fileloader::load() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:77 PHP 9. include_once() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:93

phpunit --version gives: PHPUnit 4.1.0 by Sebastian Bergmann.

Until the tests run with a simple phpunit command, there is no way, I can devote any of my work time to that.

franzliedke commented 10 years ago

Have you read these instructions?

Just execute "phpunit" in this directory instead: /usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant

John-Schlick commented 10 years ago

phpunit of tests:

jschlick@dvm-jschlick1:/usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant(BGS-1269)$ phpunit tests PHP Warning: require_once(/usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/../vendor/autoload.php): failed to open stream: No such file or directory in /usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/bootstrap.php on line 14 PHP Stack trace: PHP 1. {main}() /usr/bin/phpunit:0 PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:584 PHP 3. PHPUnit_TextUI_Command->run() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:132 PHP 4. PHPUnit_TextUI_Command->handleArguments() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:141 PHP 5. PHPUnit_TextUI_Command->handleBootstrap() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:636 PHP 6. PHPUnit_Util_Fileloader::checkAndLoad() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:806 PHP 7. PHPUnit_Util_Fileloader::load() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:77 PHP 8. include_once() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:93 PHP Fatal error: require_once(): Failed opening required '/usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/bootstrap.php on line 14 PHP Stack trace: PHP 1. {main}() /usr/bin/phpunit:0 PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:584 PHP 3. PHPUnit_TextUI_Command->run() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:132 PHP 4. PHPUnit_TextUI_Command->handleArguments() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:141 PHP 5. PHPUnit_TextUI_Command->handleBootstrap() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:636 PHP 6. PHPUnit_Util_Fileloader::checkAndLoad() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:806 PHP 7. PHPUnit_Util_Fileloader::load() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:77 PHP 8. include_once() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:93

bare phpunit in that directory:

jschlick@dvm-jschlick1:/usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant(BGS-1269)$ phpunit PHP Warning: require_once(/usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/../vendor/autoload.php): failed to open stream: No such file or directory in /usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/bootstrap.php on line 14 PHP Stack trace: PHP 1. {main}() /usr/bin/phpunit:0 PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:584 PHP 3. PHPUnit_TextUI_Command->run() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:132 PHP 4. PHPUnit_TextUI_Command->handleArguments() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:141 PHP 5. PHPUnit_TextUI_Command->handleBootstrap() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:636 PHP 6. PHPUnit_Util_Fileloader::checkAndLoad() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:806 PHP 7. PHPUnit_Util_Fileloader::load() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:77 PHP 8. include_once() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:93 PHP Fatal error: require_once(): Failed opening required '/usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant/tests/bootstrap.php on line 14 PHP Stack trace: PHP 1. {main}() /usr/bin/phpunit:0 PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:584 PHP 3. PHPUnit_TextUI_Command->run() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:132 PHP 4. PHPUnit_TextUI_Command->handleArguments() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:141 PHP 5. PHPUnit_TextUI_Command->handleBootstrap() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:636 PHP 6. PHPUnit_Util_Fileloader::checkAndLoad() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:806 PHP 7. PHPUnit_Util_Fileloader::load() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:77 PHP 8. include_once() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:93 jschlick@dvm-jschlick1:/usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant(BGS-1269)$

both complian about your bootstrap file. Clearly there is something in it that doecn't know what directory it's in becasue it can't find your autoloader.

franzliedke commented 10 years ago

Run composer install in the /usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant directory and things should work.

John-Schlick commented 10 years ago

jschlick@dvm-jschlick1:/usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant(BGS-1269)$ composer install No command 'composer' found, did you mean: Command 'compose' from package 'mime-support' (main) composer: command not found

Date: Fri, 11 Jul 2014 13:44:00 -0700 From: notifications@github.com To: GitElephant@noreply.github.com CC: John_Schlick@hotmail.com Subject: Re: [GitElephant] Support for "git branch --merged" is needed. (solution code included) (#51)

Run composer install in the /usr/local/development-process-master/common/lib/GitElephant/vendor/cypresslab/gitelephant directory and things should work.

— Reply to this email directly or view it on GitHub.

franzliedke commented 10 years ago

https://getcomposer.org/

John-Schlick commented 10 years ago

EVERY unit test I write is self contained, and WORKS NO MATTER WHICH DIRECTORY it is run out of. they work as long as the tests exist and are in the correct relationship to the project. Thats how unit tests are supposed to be written.

Why do I need to get composer and install it, and all that extra stuff just to get unit tests to work? EVERYTHING thats needed should have come with the install. Your unit tests flat out don't work.

I've done YOU a favor by writing this code and turning it over to you. I'm about to give you a bunch more code that I had to write to get for-each-ref working since I need it to get teh most recent tags, since the way you generate tag objects requires forks of an additional process per tag, wasteful, and since I have 900 tags in the repository, thats a 30 second process, which, frankly, is WAY too long for a page load.

If you insist on burdening me with configuration, I won't even bother to tell you about the cool stuff I've added to your project.

Make YOUR unit tests work if you want me to run them and add to them. without the composer crap in the way.

I am getting paid, NOT to add things to this project, but to make it work for US, you happen to get the benefit of that. If you INSIST that it must be just so, well, thats not going to happen and thats your loss.. Sorry, but I HAVE to make for-each-ref work, and my time is budgeted.

franzliedke commented 10 years ago

Hey, please calm down. This is open-source.

This is not my project, I'm just somebody wanting to help.

It just so happens that this project uses Composer for autoloading, and it does so in the test suite, too - because it makes things easier when writing the tests. No includes and whatnot.

This test suite is obviously supposed to be run a certain way (and maybe documentation can be improved here), which is different from what you expect. That does not mean it is not working.

matteosister commented 10 years ago

As @franzliedke said this is open source. Be polite and constructive, or keep up with your fork and do whatever you want with it.