Skip to content

Instantly share code, notes, and snippets.

@lashtear
Created April 14, 2016 17:16
Show Gist options
  • Save lashtear/33f7bf7fd6c4299786716cde54002b8d to your computer and use it in GitHub Desktop.
Save lashtear/33f7bf7fd6c4299786716cde54002b8d to your computer and use it in GitHub Desktop.
#! /usr/bin/perl
use warnings;
use strict;
sub slurp {
my $filename = shift;
local $/;
open my $fh, '<', $filename
or die "open: $filename: $!\n";
local $_ = <$fh>;
close $fh;
return $_;
}
sub spit {
my $filename = shift;
my $content = shift;
open my $fh, '>', $filename
or die "open: $filename: $!\n";
print $fh $content;
close $fh;
}
if (not -d '.git'
or not -f '.gitmodules') {
die "Run this tool from inside a git repo with submodules.\n";
}
my $modules_in = slurp('.gitmodules');
my $modules_out = $modules_in;
while ($modules_out =~ s{ssh://git\@stash\.symas\.com:7999/sold/(.*)$}{git\@github.com:Symas/$1}im) {
warn "changed uri for $1\n";
}
spit('.gitmodules',$modules_out)
if ($modules_in ne $modules_out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment