expandedfronts / revisr

Revisr: Git for WordPress
https://revisr.io
GNU General Public License v3.0
195 stars 41 forks source link

More detailed debug info anywhere? #8

Closed emcniece closed 9 years ago

emcniece commented 9 years ago

I'm having some issues committing to our local git server, and I'm fairly sure it's due to authentication. However, all the event messages say is "Error committing the changes to the local repository". Is there any way to get more detailed info, like an error log?

expandedfronts commented 9 years ago

Hello,

The error messages are being worked on and will be improved in an upcoming release to be more detailed on reasons for the error. However, that issue doesn't look like an authentication issue to me.

To troubleshoot the error you got I would check the following:

Let me know if you have any questions. Thank you.

emcniece commented 9 years ago

Interesting... Git as root works fine. I've loaded up a test file to try and manually commit as the web user:

echo exec('whoami');
$return = exec('git commit -am "incrementing version"', $output, $return2);

echo '<pre>'.print_r($return, true).'</pre>';
echo '<pre>'.print_r($output, true).'</pre>';
echo '<pre>'.print_r($return2, true).'</pre>';

Executing a command of git commit or git status prints the regular repo status messages, which is great... but executing the full git commit -am ... command prints empty, and the $return2 code is 128 which is afaict a mysterious failure message.

System permissions error then I guess. Git config looks like so:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[user]
    name = GitUser
    email = gituser@host.com
[revisr]
    token = z1MWAifCcsRKw8T9
[remote "origin"]
    url = http://git.server.com/clients/client123-net.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "revisr"]
    url = http://User:password@git.server.com/clients/client123-net.git
    fetch = +refs/heads/*:refs/remotes/revisr/*

We have a multi-user setup here so we like to prompt for username and password when our developer make commits. To enable Revisr to make its own commits, we run it as a "server" user and preload its authentication to the "revisr" remote. Revisr settings pages are as so:

Git Username: GitUser
Git Email: gituser@host.com

Remote Name: revisr
Remote URL: http://User:password@git.server.com/clients/client123-net.git

Upon entering the remote URL field, a green "Success!" badge appears to the right.

Currently trying to get git to execute as web user properly.

emcniece commented 9 years ago

Got it. git init should be run by the web user, not as root.

Since the repo was init with root, the .git/* files were owned by root. When git executed as web user, it couldn't access the git repo files and silently failed.

chown -R webuser:webgroup .git worked like a charm. Revisr is now fully functional.

Thanks for the tips!