Last active
November 28, 2017 15:38
-
-
Save rainbow23/210f1a5ed9bd9ec8661aecb14e90e363 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ignore_user_abort(true); | |
function syscall ($cmd, $cwd) { | |
$descriptorspec = array( | |
1 => array('pipe', 'w'), // stdout is a pipe that the child will write to | |
2 => array('pipe', 'w') // stderr | |
); | |
$resource = proc_open($cmd, $descriptorspec, $pipes, $cwd); | |
if (is_resource($resource)) { | |
$output = stream_get_contents($pipes[2]); | |
// $output .= PHP_EOL; | |
$output .= stream_get_contents($pipes[1]); | |
// $output .= PHP_EOL; | |
fclose($pipes[1]); | |
fclose($pipes[2]); | |
proc_close($resource); | |
return $output; | |
} | |
} | |
$cwd = getcwd(); | |
//print "cwd ".$cwd . "\n"; | |
$result = syscall('git clone git@github.com:rainbow23/dotfiles.git', $cwd); | |
echo sprintf("1** %s **\n", $result); | |
chdir('dotfiles'); | |
$d_dir = getcwd(); | |
print("d_dir". $d_dir . "\n"); | |
$result = syscall('git checkout fix_tmux', sprintf("%s/%s", $d_dir, 'dotfiles')); | |
echo sprintf("2** %s **\n", $result); | |
$result = syscall('git branch -r', $d_dir); | |
echo sprintf("3** %s **\n", $result); | |
$result = syscall('git checkout hogehoge', sprintf("%s/%s", $d_dir, 'dotfiles')); | |
echo sprintf("4** %s **\n", $result); | |
chdir($cwd); | |
$curr_dir = getcwd(); | |
print("curr_dir".$curr_dir."\n"); | |
exec("rm -rf dotfiles"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment