Created
January 11, 2019 07:09
-
-
Save sangheonhan/dcf094e73539991308ad3d7b8755898b to your computer and use it in GitHub Desktop.
특정 디렉토리 안의 git 저장소들을 덤프하는 펄 스크립트
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/perl | |
use strict; | |
use warnings; | |
if ( $#ARGV < 1 ) { | |
print "Usage : dumpgit.pl <git upper dir> <target dir>\n"; | |
exit 1; | |
} | |
my $gitupperdir; | |
my $dh; | |
my $gitdir; | |
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); | |
my $now = sprintf "%04d_%02d_%02d_%02d_%02d", $year + 1900, $mon + 1, $mday, $hour, $min; | |
my $targetdir; | |
$gitupperdir = shift @ARGV; | |
$targetdir = shift @ARGV; | |
opendir $dh, $gitupperdir; | |
while ( $gitdir = readdir($dh) ) { | |
if ( -d "$gitupperdir/$gitdir" && $gitdir !~ /^\.{1,2}$/ ) { | |
print "*** START - $gitupperdir/$gitdir ***\n"; | |
chdir "$gitupperdir/$gitdir"; | |
system "git bundle create $targetdir/$gitdir.bundle --all"; | |
print "*** END - $gitupperdir/$gitdir ***\n"; | |
} | |
} | |
closedir($dh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment