I am designing an application which has a layer ontop of git that would allow me to perform commits from the web browser instead of having to go CLI. The git repo will be on my own server. Part of the git process is git push origin master
, but that has a password prompt.
The exec code
private function run($command, array $arguments = array()) {
$pipes = array();
$descriptorspec = array(
array('pipe', 'r'), // STDIN
array('pipe', 'w'), // STDOUT
array('file', 'temp/error.txt', 'w'), // STDERR
);
$process = proc_open($command, $descriptorspec, $pipes);
foreach ($arguments as $arg) {
// Write each of the supplied arguments to STDIN
fwrite($pipes[0], (preg_match("/\n(:?\s+)?$/", $arg) ? $arg : "{$arg}\n"));
}
$response = stream_get_contents($pipes[1]);
// Make sure that each pipe is closed to prevent a lockout
foreach ($pipes as $pipe) {
fclose($pipe);
}
proc_close($process);
return $response;
}
and I would call the function using
$git->run('git push origin master', array('username', 'password'));
Doing the above does absolutely nothing.
During debugging of the above code, I ran php -i
and got some returned data. I then ran aasdashdlashdkashdl
, i.e. a script I know doesn't exist, and still got nothing returned and no error output either. Running git status
using this function returns an output, whereas git add .
returns nothing and does nothing to the git repo.
What am I doing wrong? Can I use certificates instead (but then you have the problem of a self signed certificate, and I may not only develop on my personal computer but others as well)?
NB
I'm trying to stay as "vanilla" as possible, and would rather not have to add loads of packages, although I am willing if there's no other solution.