├── .gitignore ├── .mailmap ├── Changes ├── META.json ├── README.pod ├── bin ├── git-spark └── git-vspark ├── dist.ini └── lib └── App └── Git └── Spark.pm /.gitignore: -------------------------------------------------------------------------------- 1 | App-Git-Spark-* 2 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | # converts from 2 | 3 | -------------------------------------------------------------------------------- /Changes: -------------------------------------------------------------------------------- 1 | 2 | 0.006 2013.03.17 09:51:10 GMT 3 | - Added 'use utf8' to App::Git::Spark 4 | 5 | 0.005 2013.03.17 09:03:19 GMT 6 | - git-vspark 7 | - POD: new install instructions 8 | - POD: introduce git-vspark 9 | - Switch from homan's git implementation to Term::Spark 10 | 11 | 0.004 2013.02.11 20:01:19 SGT 12 | - POD: better install instructions 13 | 14 | 0.003 2013.02.11 19:04:17 SGT 15 | - POD 16 | 17 | 0.002 2013.02.11 06:44:21 SGT 18 | - Added some POD 19 | 20 | 0.001 2013.02.10 18:09:08 SGT 21 | - First release 22 | -------------------------------------------------------------------------------- /META.json: -------------------------------------------------------------------------------- 1 | { 2 | "abstract" : "Plot your git commit history on the command line with sparklines", 3 | "author" : [ 4 | "Eric Johnson " 5 | ], 6 | "dynamic_config" : 0, 7 | "generated_by" : "Dist::Zilla version 4.300030, CPAN::Meta::Converter version 2.120921", 8 | "license" : [ 9 | "perl_5" 10 | ], 11 | "meta-spec" : { 12 | "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", 13 | "version" : "2" 14 | }, 15 | "name" : "App-Git-Spark", 16 | "no_index" : { 17 | "directory" : [ 18 | "t", 19 | "xt", 20 | "examples", 21 | "corpus" 22 | ], 23 | "package" : [ 24 | "DB" 25 | ] 26 | }, 27 | "prereqs" : { 28 | "configure" : { 29 | "requires" : { 30 | "ExtUtils::MakeMaker" : "6.30" 31 | } 32 | }, 33 | "develop" : { 34 | "requires" : { 35 | "Pod::Coverage::TrustPod" : "0", 36 | "Test::CPAN::Meta" : "0", 37 | "Test::Pod" : "1.41", 38 | "Test::Pod::Coverage" : "1.08" 39 | } 40 | }, 41 | "runtime" : { 42 | "requires" : { 43 | "DateTime" : "0", 44 | "Encode" : "0", 45 | "Getopt::Long::Descriptive" : "0", 46 | "List::AllUtils" : "0", 47 | "Math::Round" : "0", 48 | "Term::Spark" : "0", 49 | "Term::Vspark" : "0", 50 | "perl" : "5.008", 51 | "strict" : "0", 52 | "utf8" : "0", 53 | "warnings" : "0" 54 | } 55 | }, 56 | "test" : { 57 | "requires" : { 58 | "ExtUtils::MakeMaker" : "0", 59 | "File::Find" : "0", 60 | "File::Spec::Functions" : "0", 61 | "File::Temp" : "0", 62 | "List::Util" : "0", 63 | "Test::More" : "0" 64 | } 65 | } 66 | }, 67 | "provides" : { 68 | "App::Git::Spark" : { 69 | "file" : "lib/App/Git/Spark.pm", 70 | "version" : "0.006" 71 | } 72 | }, 73 | "release_status" : "stable", 74 | "resources" : { 75 | "bugtracker" : { 76 | "web" : "https://github.com/kablamo/git-spark/issues" 77 | }, 78 | "homepage" : "https://metacpan.org/release/App-Git-Spark", 79 | "repository" : { 80 | "type" : "git", 81 | "url" : "git://github.com/kablamo/git-spark.git", 82 | "web" : "https://github.com/kablamo/git-spark" 83 | } 84 | }, 85 | "version" : "0.006", 86 | "x_contributors" : [ 87 | "Eric Johnson " 88 | ] 89 | } 90 | 91 | -------------------------------------------------------------------------------- /README.pod: -------------------------------------------------------------------------------- 1 | =pod 2 | 3 | =encoding utf-8 4 | 5 | =head1 NAME 6 | 7 | App::Git::Spark - Plot your git commit history on the command line with sparklines 8 | 9 | =head1 SYNOPSIS 10 | 11 | $ git spark --days 14 Stegosaurus 12 | Commits by Stegosaurus over the last 14 days 13 | total: 95 avg: 7 max: 23 14 | 10 15 6 23 5 0 0 1 15 0 17 3 0 0 15 | ▄▅▂█▂▁▁▁▅▁▆▁▁▁ 16 | 17 | $ git vspark --months 10 Triceratops 18 | Commits by Triceratops over the last 10 months 19 | total: 263 avg: 26 max: 72 20 | 12 ██▋ 21 | 18 ███▉ 22 | 72 ███████████████▏ 23 | 56 ███████████▊ 24 | 16 ███▍ 25 | 28 █████▉ 26 | 12 ██▋ 27 | 19 ████ 28 | 19 ████ 29 | 11 ██▍ 30 | 31 | $ git spark -h 32 | usage: git spark [-dhmoswy] [long options...] [AUTHOR] 33 | -o --hours Commits from the last x hours 34 | -d --days Commits from the last x days 35 | -w --weeks Commits from the last x weeks 36 | -m --months Commits from the last x months 37 | -y --years Commits from the last x years 38 | -s --scale Set the max value of the graph. Use this option to 39 | compare this graph with other graphs. 40 | -h --help Show this message 41 | 42 | =head1 DESCRIPTION 43 | 44 | Plot your git commit history on the commandline with sparklines and "vertical" 45 | sparklines. 46 | 47 | =head1 COMPARING GRAPHS 48 | 49 | Comparing graphs is often difficult because the scaling changes for different 50 | data sets. For example these two data series produce identical graphs despite 51 | have very different data. 52 | 53 | $ spark 1 2 3 4 5 54 | ▁▂▄▆█ 55 | $ spark 10 20 30 40 50 56 | ▁▂▄▆█ 57 | 58 | To solve this, you must put a max and a min in front of the data to get 59 | consistent scaling. For example: 60 | 61 | $ spark 50 1 1 2 3 4 5 62 | █▁▁▁▁▁▁ 63 | $ spark 50 1 10 20 30 40 50 64 | █▁▂▃▅▆█ 65 | 66 | git-spark assumes the min is zero and users can pass in the max using 67 | the --scale option. (Note that git-spark chops off the max/min characters from 68 | the output so this is all hidden behind the scenes.) 69 | 70 | The --scale option is also relavent to git-vspark. 71 | 72 | =head1 INSTALLATION 73 | 74 | L is the standard tool the 75 | Perl community uses to download and install Perl libraries from the 76 | L. The following should get you up and running 77 | quickly: 78 | 79 | curl -L http://cpanmin.us | perl - --sudo App::cpanminus 80 | cpanm App::Git::Spark 81 | 82 | =head1 SEE ALSO 83 | 84 | L 85 | 86 | L 87 | 88 | =head1 AUTHOR 89 | 90 | Eric Johnson 91 | 92 | =head1 COPYRIGHT AND LICENSE 93 | 94 | This software is copyright (c) 2013 by Eric Johnson. 95 | 96 | This is free software; you can redistribute it and/or modify it under 97 | the same terms as the Perl 5 programming language system itself. 98 | 99 | -------------------------------------------------------------------------------- /bin/git-spark: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Inspired by @trisweb: 3 | # http://github.com/holman/spark/wiki/Wicked-Cool-Usage 4 | 5 | use strict; 6 | use warnings; 7 | 8 | use Getopt::Long::Descriptive; 9 | use Encode qw/encode decode/; 10 | use DateTime; 11 | use List::AllUtils qw/max sum/; 12 | use Math::Round qw/round/; 13 | use Term::Spark qw/show_graph/; 14 | 15 | binmode STDOUT, ':encoding(UTF-8)'; 16 | 17 | # VERSION 18 | # PODNAME: git-spark 19 | 20 | =head1 DESCRIPTION 21 | 22 | See L for documentation. 23 | 24 | =cut 25 | 26 | my ($option, $usage) = describe_options( 27 | 'usage: git spark %o [AUTHOR]', 28 | ['hours|o=i' => 'Commits from the last x hours'], 29 | ['days|d=i' => 'Commits from the last x days'], 30 | ['weeks|w=i' => 'Commits from the last x weeks'], 31 | ['months|m=i' => 'Commits from the last x months'], 32 | ['years|y=i' => 'Commits from the last x years'], 33 | ['scale|s=i' => 'Set the max value of the graph. Use this option to compare this graph with other graphs.'], 34 | ['help|h' => 'Show this message'], 35 | ); 36 | 37 | my $author = $ARGV[0] || $ENV{USER}; 38 | my $scale = $option->scale || 0; 39 | 40 | print($usage), exit 0 if $option->help; 41 | print($usage), exit 0 42 | if (!$option->hours && 43 | !$option->days && 44 | !$option->weeks && 45 | !$option->months && 46 | !$option->years); 47 | 48 | foreach my $key (qw/hours days weeks months years/) { 49 | spark($option->$key, $key, $author, $scale) if $option->$key; 50 | } 51 | 52 | sub spark { 53 | my ($value, $units, $author, $scale) = @_; 54 | 55 | my @data = countCommits(@_); 56 | my $total = sum @data; 57 | my $avg = round($total / ($#data + 1)); 58 | my $max = max @data; 59 | 60 | print "Commits by $author over the last $value $units\n"; 61 | print "total: $total avg: $avg max: $max\n"; 62 | print join(" ", @data) . "\n"; 63 | print show_graph( max => $max, values => \@data ), "\n"; 64 | } 65 | 66 | sub countCommits { 67 | my ($value, $units, $author) = @_; 68 | 69 | my @commits; 70 | foreach my $i (0..($value - 1)) { 71 | my $cmd = "git log " . 72 | "--author=${author} " . 73 | "--before='${i} ${units}' " . 74 | "--after='" . ($i + 1) . " ${units}' " . 75 | "--format=oneline | wc -l"; 76 | my $count = `$cmd`; 77 | chomp($count); 78 | push @commits, $count; 79 | } 80 | 81 | return reverse @commits; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /bin/git-vspark: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Getopt::Long::Descriptive; 7 | use DateTime; 8 | use List::AllUtils qw/max sum/; 9 | use Math::Round qw/round/; 10 | use Term::Vspark qw/show_graph/; 11 | 12 | binmode STDOUT, ':encoding(UTF-8)'; 13 | 14 | # VERSION 15 | # PODNAME: git-spark 16 | 17 | my ($option, $usage) = describe_options( 18 | 'usage: git vspark %o [AUTHOR]', 19 | ['hours|o=i' => 'Commits from the last x hours'], 20 | ['days|d=i' => 'Commits from the last x days'], 21 | ['weeks|w=i' => 'Commits from the last x weeks'], 22 | ['months|m=i' => 'Commits from the last x months'], 23 | ['years|y=i' => 'Commits from the last x years'], 24 | ['scale|s=i' => 'Set the max value of the graph. Use this option to compare this graph with other graphs.'], 25 | ['help|h' => 'Show this message'], 26 | ); 27 | 28 | my $author = $ARGV[0] || $ENV{USER}; 29 | my $scale = $option->scale || 0; 30 | 31 | print($usage), exit 0 if $option->help; 32 | print($usage), exit 0 33 | if (!$option->hours && 34 | !$option->days && 35 | !$option->weeks && 36 | !$option->months && 37 | !$option->years); 38 | 39 | foreach my $key (qw/hours days weeks months years/) { 40 | vspark($option->$key, $key, $author, $scale) if $option->$key; 41 | } 42 | 43 | sub vspark { 44 | my ($value, $units, $author, $scale) = @_; 45 | 46 | my @commits = countCommits(@_); 47 | my $total = sum @commits; 48 | my $avg = round($total / scalar @commits); 49 | my $max = max @commits; 50 | 51 | print "Commits by $author over the last $value $units\n"; 52 | print "total: $total avg: $avg max: $max\n"; 53 | print STDOUT show_graph( 54 | max => $scale ? $scale : $max, 55 | columns => 20, 56 | values => \@commits, 57 | labels => \@commits, 58 | ); 59 | } 60 | 61 | sub countCommits { 62 | my ($value, $units, $author) = @_; 63 | 64 | my @commits; 65 | foreach my $i (0..($value - 1)) { 66 | my $cmd = "git log " . 67 | "--author=${author} " . 68 | "--before='${i} ${units}' " . 69 | "--after='" . ($i + 1) . " ${units}' " . 70 | "--format=oneline | wc -l"; 71 | my $count = `$cmd`; 72 | chomp($count); 73 | push @commits, $count; 74 | } 75 | 76 | return @commits; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /dist.ini: -------------------------------------------------------------------------------- 1 | name = App-Git-Spark 2 | author = Eric Johnson 3 | license = Perl_5 4 | copyright_holder = Eric Johnson 5 | main_module = lib/App/Git/Spark.pm 6 | 7 | [@DAGOLDEN] 8 | no_critic = 1 9 | no_spellcheck = 1 10 | AutoMetaResources.bugtracker.rt = 0 11 | AutoMetaResources.repository.github = user:kablamo;dist:git-spark;lcdist:git-spark 12 | AutoMetaResources.bugtracker.github = user:kablamo;dist:git-spark;lcdist:git-spark 13 | weaver_config = @FLORA 14 | -------------------------------------------------------------------------------- /lib/App/Git/Spark.pm: -------------------------------------------------------------------------------- 1 | package App::Git::Spark; 2 | use utf8; 3 | 4 | # VERSION 5 | 6 | # ABSTRACT: Plot your git commit history on the command line with sparklines 7 | 8 | =head1 SYNOPSIS 9 | 10 | $ git spark --days 14 Stegosaurus 11 | Commits by Stegosaurus over the last 14 days 12 | total: 95 avg: 7 max: 23 13 | 10 15 6 23 5 0 0 1 15 0 17 3 0 0 14 | ▄▅▂█▂▁▁▁▅▁▆▁▁▁ 15 | 16 | $ git vspark --months 10 Triceratops 17 | Commits by Triceratops over the last 10 months 18 | total: 263 avg: 26 max: 72 19 | 12 ██▋ 20 | 18 ███▉ 21 | 72 ███████████████▏ 22 | 56 ███████████▊ 23 | 16 ███▍ 24 | 28 █████▉ 25 | 12 ██▋ 26 | 19 ████ 27 | 19 ████ 28 | 11 ██▍ 29 | 30 | $ git spark -h 31 | usage: git spark [-dhmoswy] [long options...] [AUTHOR] 32 | -o --hours Commits from the last x hours 33 | -d --days Commits from the last x days 34 | -w --weeks Commits from the last x weeks 35 | -m --months Commits from the last x months 36 | -y --years Commits from the last x years 37 | -s --scale Set the max value of the graph. Use this option to 38 | compare this graph with other graphs. 39 | -h --help Show this message 40 | 41 | =head1 DESCRIPTION 42 | 43 | Plot your git commit history on the commandline with sparklines and "vertical" 44 | sparklines. 45 | 46 | =head1 COMPARING GRAPHS 47 | 48 | Comparing graphs is often difficult because the scaling changes for different 49 | data sets. For example these two data series produce identical graphs despite 50 | have very different data. 51 | 52 | $ spark 1 2 3 4 5 53 | ▁▂▄▆█ 54 | $ spark 10 20 30 40 50 55 | ▁▂▄▆█ 56 | 57 | To solve this, you must put a max and a min in front of the data to get 58 | consistent scaling. For example: 59 | 60 | $ spark 50 1 1 2 3 4 5 61 | █▁▁▁▁▁▁ 62 | $ spark 50 1 10 20 30 40 50 63 | █▁▂▃▅▆█ 64 | 65 | git-spark assumes the min is zero and users can pass in the max using 66 | the --scale option. (Note that git-spark chops off the max/min characters from 67 | the output so this is all hidden behind the scenes.) 68 | 69 | The --scale option is also relavent to git-vspark. 70 | 71 | =head1 INSTALLATION 72 | 73 | L is the standard tool the 74 | Perl community uses to download and install Perl libraries from the 75 | L. The following should get you up and running 76 | quickly: 77 | 78 | curl -L http://cpanmin.us | perl - --sudo App::cpanminus 79 | cpanm App::Git::Spark 80 | 81 | =head1 SEE ALSO 82 | 83 | L 84 | 85 | L 86 | 87 | =cut 88 | --------------------------------------------------------------------------------