findGitlab.pl
1	#!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 my $pwd = `echo \$PWD`;
7 chomp $pwd;
8 print "PWD is: $pwd\n";
9
10 sub find_origin {
11 my $path = shift;
12 my $configFile = $path . "config";
13 if ( -f $configFile ) {
14 my $origin = `cat $configFile | grep url | awk {'print \$3}'`;
15 chomp $origin;
16 my $replaceSite = "spwbk.site:";
17 if ( $origin =~ m/@(.*)\:/ ) {
18 if ( $1 ne "spwbk.site" ) {
19 print "$path has origin: $origin that does not match spwbk.site\n";
20 print "cd'ing into $path...\n";
21 my $replaceCmd = "sed -i s?$1:spesk1/?$replaceSite?g $configFile";
22 print "Using sed to replace $1 with spwbk.site -> $replaceCmd\n";
23 my $output = `$replaceCmd`;
24 chomp $output;
25 print "Output was: $output\n";
26 }
27 }
28 }
29 }
30
31 sub find_git {
32 my $path = shift;
33 my $gitDirPath = $path . ".git/";
34 if ( -d $gitDirPath ) {
35 find_origin($gitDirPath);
36
37 }
38 }
39
40
41 foreach my $dir ( split("\n",`ls -d */`) ) {
42 chomp $dir;
43 find_git($dir);
44 }