diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-11-08 14:52:42 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-11-08 14:52:42 -0600 |
commit | 036eb2d7b5db9f65c8991be91e1c567d6fbb0399 (patch) | |
tree | d9bc29a9aea8bb551835d8f242b63f970c9d96c3 /bin/git | |
parent | 96690c276df5f1f8389e81d273113c85a285b36d (diff) | |
download | conf-036eb2d7b5db9f65c8991be91e1c567d6fbb0399.tar.gz conf-036eb2d7b5db9f65c8991be91e1c567d6fbb0399.zip |
make git helper scripts available to the main git program
Diffstat (limited to 'bin/git')
-rwxr-xr-x | bin/git/git-author-stat | 8 | ||||
-rwxr-xr-x | bin/git/git-blame-stats | 37 | ||||
-rwxr-xr-x | bin/git/git-file-size | 3 | ||||
-rwxr-xr-x | bin/git/git-unmerged | 30 |
4 files changed, 78 insertions, 0 deletions
diff --git a/bin/git/git-author-stat b/bin/git/git-author-stat new file mode 100755 index 0000000..4747fce --- /dev/null +++ b/bin/git/git-author-stat @@ -0,0 +1,8 @@ +#!/bin/bash + +git log "$@" | \ +git shortlog | \ +perl -ne 'print if/^\S+/' | \ +perl -pe 's/(.*)\((\d+)\).*/$2: $1/' | \ +sort -gr | \ +less -MSi; diff --git a/bin/git/git-blame-stats b/bin/git/git-blame-stats new file mode 100755 index 0000000..320d755 --- /dev/null +++ b/bin/git/git-blame-stats @@ -0,0 +1,37 @@ +#!/usr/bin/perl + +use Getopt::Long; +use POSIX qw(ceil); +use strict; +Getopt::Long::Configure(qw(bundling)); +my %authors; +my $total; +my $files; +my $rev = shift(@ARGV) || "HEAD"; + +foreach my $file (`git ls-tree --name-only -r $rev`) { + chomp($file); + print STDERR "Processing $file\n"; + foreach my $line (`git blame -M -w $rev -- "$file"`) { + chomp($line); + if (substr($line, 0, 1) eq "^") { + ++$authors{"*initial checkin"}; + } else { + $line =~ s[^.*?\((.*?)\s*\d{4}-\d{2}-\d{2}.*][$1]; + ++$authors{$line}; + } + ++$total; + } +} + +print "Total lines: $total\n"; +my $i = 0; +my $author_ind = ceil(log(scalar(keys %authors)) / log(10)); +my $lines_ind = ceil(log($total) / log(10)); +foreach my $author (sort { $authors{$b} <=> $authors{$a} } keys %authors) { + printf "%${author_ind}s %${lines_ind}u %5.2f%% %s\n", + sprintf("#%u", ++$i), + $authors{$author}, + $authors{$author} * 100 / $total, + $author; +} diff --git a/bin/git/git-file-size b/bin/git/git-file-size new file mode 100755 index 0000000..6178063 --- /dev/null +++ b/bin/git/git-file-size @@ -0,0 +1,3 @@ +#!/bin/sh + +git ls-files | xargs du -b | sum diff --git a/bin/git/git-unmerged b/bin/git/git-unmerged new file mode 100755 index 0000000..4e16caf --- /dev/null +++ b/bin/git/git-unmerged @@ -0,0 +1,30 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +sub git { + if (wantarray) { + chomp(my @ret = qx{git $_[0]}); + return @ret; + } + else { + chomp(my $ret = qx{git $_[0]}); + return $ret; + } +} + +my $branch = git 'symbolic-ref HEAD'; +$branch ||= 'master'; +$branch =~ s:^refs/heads/::; + +my @remotes = git 'remote show'; +my %remotes = map { $_, "$_/$branch" } @remotes; + +for my $remote (keys %remotes) { + my $remote_branch = $remotes{$remote}; + my $tip = git "show-ref -s --abbrev $remote_branch"; + my $merge_base = git "merge-base HEAD $remote_branch"; + $merge_base = substr $merge_base, 0, 7; + next if $merge_base eq $tip; + print "$remote: $merge_base..$tip\n"; +} |