Created
November 28, 2016 11:03
-
-
Save forsvunnet/aaeeb0d0c5d78286defcc669dfd6ac73 to your computer and use it in GitHub Desktop.
Log checker
This file contains hidden or 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 | |
$base_path = '/Users/eivin.landa/Workspace'; | |
$who = 'Eivin'; | |
$repos = [ | |
'AVREmea/emea.dev', | |
'Exist/exist.dev', | |
'Soma/soma.dev', | |
'Soma/soma.dev/wp-content/plugins/wordpress-nginx-fullpage-cache', | |
'Soma/soma.dev/wp-content/plugins/craft-improved-checkout', | |
'Vakrerom/vakrerom.dev', | |
'YMEUniverse/yme.dev', | |
'bogart/bogart.dev', | |
]; | |
$history = []; | |
date_default_timezone_set( 'Europe/Oslo' ); | |
function breakup_log( $log ) { | |
$parts = explode( "\ncommit", $log ); | |
$parts[0] = preg_replace( '/^commit/', '', $parts[0] ); | |
$commits = []; | |
foreach ( $parts as $part ) { | |
$commits[] = format_part( $part ); | |
} | |
return $commits; | |
} | |
function format_part( $part ) { | |
$lines = explode( "\n", $part ); | |
$commit['sha'] = array_shift( $lines ); | |
$commit['author'] = array_shift( $lines ); | |
if ( false !== strpos( $commit['author'], 'Merge: ' ) ) { | |
$commit['merge'] = $commit['author']; | |
$commit['merge'] = preg_replace( '/^Merge: /', '', $commit['merge'] ); | |
$commit['author'] = array_shift( $lines ); | |
} | |
$commit['author'] = preg_replace( '/^Author: /', '', $commit['author'] ); | |
$commit['date'] = array_shift( $lines ); | |
$commit['date'] = preg_replace( '/^Date: /', '', $commit['date'] ); | |
$commit['message'] = implode( "\n", $lines ); | |
foreach ( $commit as &$part ) { | |
$part = trim( $part ); | |
} | |
$lines = explode( "\n", $commit['message'] ); | |
$commit['title'] = $lines[0]; | |
return $commit; | |
} | |
$projects = []; | |
foreach ( $repos as $repo ) { | |
chdir( "{$base_path}/{$repo}" ); | |
$projects[$repo] = breakup_log( `git log --since="2016-11-22T00:00:00"` ); | |
} | |
$all_commits = []; | |
foreach ( $projects as $repo => $commits ) { | |
foreach ( $commits as $commit ) { | |
$commit['project'] = $repo; | |
$time = strtotime( $commit['date'] ); | |
$all_commits[$time] = $commit; | |
} | |
} | |
ksort( $all_commits ); | |
$prev = 0; | |
foreach ( $all_commits as $time => $commit ) { | |
if ( false === strpos( $commit['author'], $who ) ) { | |
continue; | |
} | |
$date = date( 'Y-m-d l', $time ); | |
if ( $date !== $prev_date ) { | |
echo "\n\033[32m{$date}\033[0m\n"; | |
if ( $prev == $commit['project'] ) { | |
echo "\033[31m{$commit['project']}\033[0m\n"; | |
} | |
} | |
if ( $prev !== $commit['project'] ) { | |
echo "\033[31m{$commit['project']}\033[0m\n"; | |
} | |
echo "[\033[34m". date( 'H:i:s', $time ) ."\033[0m] "; | |
// echo "\033[32m{$commit['author']}\033[0m\n"; | |
if ( $commit['merge'] ) { | |
echo "{$commit['title']}\n"; | |
} else { | |
echo "\033[37m{$commit['title']}\033[0m\n"; | |
} | |
$prev = $commit['project']; | |
$prev_date = $date; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment