findGitlab.pl 942 B

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