summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-22 16:59:06 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-22 17:11:47 +0530
commitc58bea2d65611f6ccf3172e1d87a5e6ce69d6a90 (patch)
tree56a5f7daf04b64b35edaffd91a921f58425c6e2c /crawl-ref/source/util
parent897ce67495a1a5c2535372c21ea72cd7b821f237 (diff)
downloadcrawl-ref-c58bea2d65611f6ccf3172e1d87a5e6ce69d6a90.tar.gz
crawl-ref-c58bea2d65611f6ccf3172e1d87a5e6ce69d6a90.zip
Retrieved names lost from CREDITS.
Diffstat (limited to 'crawl-ref/source/util')
-rw-r--r--crawl-ref/source/util/salvage-credits.pl69
1 files changed, 69 insertions, 0 deletions
diff --git a/crawl-ref/source/util/salvage-credits.pl b/crawl-ref/source/util/salvage-credits.pl
new file mode 100644
index 0000000000..ab0f4fe6cc
--- /dev/null
+++ b/crawl-ref/source/util/salvage-credits.pl
@@ -0,0 +1,69 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use Encode;
+
+binmode STDOUT, ':utf8';
+
+print "Fetching all historical contributors for CREDITS\n";
+my @shas = qx/git log --pretty=oneline --follow CREDITS.txt/;
+s/^(\w+).*/$1/ for @shas;
+
+my $contributors = '';
+
+fetch_contributors($_) for @shas;
+
+print "Going back to master\n";
+system "git checkout master" and die "git checkout master failed\n";
+
+open my $outf, '>>', 'CREDITS.txt' or die "Can't write CREDITS.txt\n";
+binmode $outf, ':utf8';
+print $outf "\n$contributors\n";
+close $outf;
+
+print "Contributors appended to CREDITS.txt!\n";
+
+sub fetch_contributors {
+ my $sha = shift;
+ print "Visiting $sha credits.\n";
+ system "git checkout $sha" and die "git checkout $sha failed\n";
+ $contributors .= credits_names();
+}
+
+sub find_credits {
+ my @tests = grep(-f, ('CREDITS.txt', 'CREDITS'));
+ die "Cannot find CREDITS file\n" unless @tests;
+ return $tests[0];
+}
+
+sub decodeText {
+ my $bytes = shift;
+ eval {
+ $bytes = decode('utf-8', $bytes, 1);
+ return $bytes;
+ };
+ eval {
+ $bytes = decode('iso-8859-1', $bytes, 1);
+ return $bytes;
+ };
+ $bytes
+}
+
+sub credits_names {
+ my $file = find_credits();
+ open my $inf, '<', $file or die "Can't read $file: $!\n";
+ binmode $inf;
+ my @lines = <$inf>;
+ close $inf;
+ my $res = '';
+ my $incontributors;
+ for (@lines) {
+ chomp;
+ $_ = decodeText($_);
+ $_ .= "\n";
+ $res .= $_ if $incontributors && /\S/;
+ $incontributors = 1 if !$incontributors && /contributed.*:\s*$/;
+ }
+ $res
+}