Guest User

Untitled

a guest
Mar 6th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. <?php
  2.  
  3. $repos = ['demo','collective','eiq360','swiftmail','legion','ensembleiq'];
  4. $current_time = time();
  5. $i=0;
  6. $user_commits = [];
  7. $year_months = [];
  8. while($i<7){
  9. foreach($repos as $repo){
  10. $year_month = date('Y-m',strtotime("-$i months"));
  11. $out = [];
  12. $outputs = [];
  13. exec("git -C ~/git/$repo shortlog -ns --since='$year_month-01' --before='$year_month-31'", $outputs);
  14. foreach($outputs as $output){
  15. $split = explode("\t",$output);
  16. $commit_count = $split[0];
  17. $user = $split[1];
  18. if($user == 'jstapp'){
  19. $user = 'Josh Stapp';
  20. }elseif($user == 'Pantheon Automation'){
  21. $user = 'Pantheon';
  22. }
  23. $year_months[$year_month] = 0;
  24. if(!isset($user_commits[$user]['total'])){
  25. $user_commits[$user]['total'] = 0;
  26. }
  27. $user_commits[$user]['total'] += $commit_count;
  28. if(!isset($user_commits[$user][$repo])){
  29. $user_commits[$user][$repo] = 0;
  30. }
  31. $user_commits[$user][$repo] += $commit_count;
  32. if(!isset($user_commits[$user][$year_month])){
  33. $user_commits[$user][$year_month] = 0;
  34. }
  35. $user_commits[$user][$year_month] += $commit_count;
  36. }
  37. }
  38. $i++;
  39. }
  40.  
  41. $fields = array_merge(array_keys($year_months), $repos, ['total']);
  42. echo "User\t";
  43. foreach($fields as $field){
  44. echo "\t".substr($field,0,7);
  45. }
  46. echo "\n";
  47. foreach($user_commits as $user => $user_commit) {
  48. echo $user;
  49. if(strlen($user) < 8){
  50. echo "\t";
  51. }
  52. foreach ($fields as $field) {
  53. if (isset($user_commit[$field])) {
  54. echo "\t$user_commit[$field]";
  55. }
  56. else {
  57. echo "\t0";
  58. }
  59. }
  60. echo "\n";
  61. }
Advertisement
Add Comment
Please, Sign In to add comment