Skip to content

Instantly share code, notes, and snippets.

@deyvin
Created April 17, 2012 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deyvin/2408240 to your computer and use it in GitHub Desktop.
Save deyvin/2408240 to your computer and use it in GitHub Desktop.
Brincando com shell_exec do php com git
<?php
function limpa_array($array) {
foreach($array as $arr)
if($arr != '')
$retorno[] = $arr;
return $retorno;
}
echo "<h1>Colaboradores</h1>";
echo "<pre>";
echo shell_exec('git log --format=\'%an\' |sort -u');
echo "</pre>";
$shell = shell_exec('git log --date=relative --pretty=format:"quebralinha%ad||%s||%an||" --stat');
$array = explode("quebralinha", $shell);
foreach($array as $arr) {
if($arr != '') {
$dados = explode("||", $arr);
$files_arr = explode("|", str_replace("\n", "|", $dados[3]));
$files_arr = limpa_array($files_arr);
$retorno[] = array('funcionario' => $dados[2], 'descricao' => utf8_decode($dados[1]), 'data' => $dados[0], 'str_files' => $files_arr);
}
}
echo count($retorno) . " Commits";
echo "<h1>Ultimas Alteracoes</h1>";
echo "<pre>";
print_r($retorno);
echo "</pre>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment