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

Fatal error with WordPress as a submodule #1

Open
pdewouters opened this issue Dec 22, 2014 · 7 comments
Open

Fatal error with WordPress as a submodule #1

pdewouters opened this issue Dec 22, 2014 · 7 comments

Comments

@pdewouters
Copy link

Fatal error: Uncaught exception 'Exception' with message '"/srv/www/rrr.dev/wordpress" is not a git repository' in /home/vagrant/.wp-cli/commands/gh/vendor/kbjr/Git.php/Git.php:210
Stack trace:
#0 /home/vagrant/.wp-cli/commands/gh/vendor/kbjr/Git.php/Git.php(172): GitRepo->set_repo_path('/srv/www/rrrr...', false, true)
#1 /home/vagrant/.wp-cli/commands/gh/vendor/kbjr/Git.php/Git.php(83): GitRepo->__construct('/srv/www/rrrr...')
#2 /home/vagrant/.wp-cli/commands/gh/wp-cli-git-helper.php(56): Git::open('/srv/www/rrr...')
#3 [internal function]: Git_Helper_Command->__invoke(Array, Array)
#4 phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(52): call_user_func(Array, Array, Array)
#5 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#6 phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php(293): call_user_func(Object(Closure), Array, Array)
#7 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(304): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array in /home/vagrant/.wp-cli/commands/gh/vendor/kbjr/Git.php/Git.php on line 210
@boonebgorges
Copy link
Owner

Thanks for the report. This is happening because your git repo is not located at ABSPATH. For the moment, this is hardcoded into the tool, though there's a note that says to fix it! https://github.com/boonebgorges/wp-cli-git-helper/blob/master/wp-cli-git-helper.php#L55

@pdewouters
Copy link
Author

ok thanks!

@boonebgorges
Copy link
Owner

You got it! A proper fix for this is pretty straightforward - instead of hardcoding ABSPATH here https://github.com/boonebgorges/wp-cli-git-helper/blob/master/wp-cli-git-helper.php#L56, it would be set by an $assoc_args param, which would default to ABSPATH. Pull requests welcome :) Or you can just hardcode the proper path yourself.

@pdewouters
Copy link
Author

Sure, I'll do a PR :)

@micahjon
Copy link
Contributor

Just ran into this too. Another solution might be to search recursively from WP_PLUGIN_DIR up the directory tree until a directory is found with a .git folder. This would work for basic installs and ones where Wordpress is a submodule.

@micahjon
Copy link
Contributor

micahjon commented Mar 7, 2016

Should I submit a PR for this? Currently I just check if WP_PLUGIN_DIR or it's parent/grandparent directory contains a Git repo, and use the first one I find (or print an error message).

@boonebgorges
Copy link
Owner

Walking up the tree recursively seems dangerous to me - you wouldn't want to accidentally commit to the incorrect repo. A PR that implements this idea #1 (comment) seems safer to me. (You can then define a default for the new flag in your wp-cli.yml file.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants