Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $repos = ['demo','collective','eiq360','swiftmail','legion','ensembleiq'];
- $current_time = time();
- $i=0;
- $user_commits = [];
- $year_months = [];
- while($i<7){
- foreach($repos as $repo){
- $year_month = date('Y-m',strtotime("-$i months"));
- $out = [];
- $outputs = [];
- exec("git -C ~/git/$repo shortlog -ns --since='$year_month-01' --before='$year_month-31'", $outputs);
- foreach($outputs as $output){
- $split = explode("\t",$output);
- $commit_count = $split[0];
- $user = $split[1];
- if($user == 'jstapp'){
- $user = 'Josh Stapp';
- }elseif($user == 'Pantheon Automation'){
- $user = 'Pantheon';
- }
- $year_months[$year_month] = 0;
- if(!isset($user_commits[$user]['total'])){
- $user_commits[$user]['total'] = 0;
- }
- $user_commits[$user]['total'] += $commit_count;
- if(!isset($user_commits[$user][$repo])){
- $user_commits[$user][$repo] = 0;
- }
- $user_commits[$user][$repo] += $commit_count;
- if(!isset($user_commits[$user][$year_month])){
- $user_commits[$user][$year_month] = 0;
- }
- $user_commits[$user][$year_month] += $commit_count;
- }
- }
- $i++;
- }
- $fields = array_merge(array_keys($year_months), $repos, ['total']);
- echo "User\t";
- foreach($fields as $field){
- echo "\t".substr($field,0,7);
- }
- echo "\n";
- foreach($user_commits as $user => $user_commit) {
- echo $user;
- if(strlen($user) < 8){
- echo "\t";
- }
- foreach ($fields as $field) {
- if (isset($user_commit[$field])) {
- echo "\t$user_commit[$field]";
- }
- else {
- echo "\t0";
- }
- }
- echo "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment