[Bps-public-commit] git-mailer branch, master, updated. c6918deff0f95284f33f78ce258790e5108fa915
Alex Vandiver
alexmv at bestpractical.com
Mon Mar 22 12:22:34 EDT 2010
The branch, master has been updated
via c6918deff0f95284f33f78ce258790e5108fa915 (commit)
from 2240abe78a40b2d6333e369361b9e9fec3f9db2b (commit)
Summary of changes:
move-git | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 71 insertions(+), 0 deletions(-)
create mode 100755 move-git
- Log -----------------------------------------------------------------
commit c6918deff0f95284f33f78ce258790e5108fa915
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Mar 22 12:22:27 2010 -0400
Tool to locate and move git repositories to new hosts
diff --git a/move-git b/move-git
new file mode 100755
index 0000000..3d7ac4f
--- /dev/null
+++ b/move-git
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Config::GitLike::Git;
+use YAML;
+
+my %update;
+$update{$_}++ for
+ qw/
+ fsck.com
+ svn.bestpractical.com
+ diesel.bestpractical.com
+ booth.bestpractical.com
+ code.bestpractical.com
+ s.ly
+ /;
+
+
+my $go = 0;
+$go = 1 if @ARGV and $ARGV[0] eq "--go-for-it";
+
+my @files = split /\n/, `locate .git/config`;
+
+my %seen;
+my %notice;
+for my $filename (@files) {
+ chomp $filename;
+ next unless -w $filename;
+ my $c = Config::GitLike::Git->new;
+ $c->data({});
+ $c->load_file($filename);
+ my %data = $c->dump;
+ my @remotes = grep {/^remote\.([^.]+)\.url/} keys %data;
+ @remotes = grep { $data{$_} !~ m{^[a-z+]+://}i } @remotes;
+ @remotes = grep { $data{$_} =~ m{^[a-z0-9\.]+:}i } @remotes;
+
+ for my $key (@remotes) {
+ my ($user, $host, $path) = $data{$key} =~ /^(.*?@)?(.*?):(.*)/
+ or die "?? $key";
+ if ($go) {
+ next unless $update{$host};
+ print "Updating $filename\n";
+ my $new = ($user||"") . "git.bestpractical.com:$path";
+ $c->set(
+ key => $key,
+ value => $new,
+ filename => $filename,
+ );
+ } else {
+ $seen{$host}++;
+ $notice{$filename}++ if $update{$host};
+ }
+ }
+}
+
+unless ($go) {
+ print "Would update:\n";
+ print " $_\n" for grep {$notice{$_}} @files;
+ print "\n";
+
+ print "Found hosts:\n";
+ for my $host (sort {$seen{$a} <=> $seen{$b}} keys %seen) {
+ print " $host: $seen{$host}";
+ print " <= will be updated" if $update{$host};
+ print "\n";
+ }
+
+ print "\n";
+ print "Run again with --go-for-it if that looks good\n";
+}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list