воскресенье, 26 апреля 2015 г.

how hack git

Hi, my script to full github history and make longest stick:
https://github.com/mishin/presentation/blob/master/01_test_git.pl






use Modern::Perl;
use Git::Repository;
use File::Slurp qw( :edit );
my $url = 'https://github.com/mishin/perldoc-ru.git';
my $dir = '/home/mishin/github/test_repo';
#Git::Repository->run( clone => $url => $dir );
my $r = Git::Repository->new( work_tree => $dir );
use DateTime;
use DateTime::Format::Strptime;
my $dt = DateTime->new(
year => 2015,
month => 02,
day => 07,
hour => 16,
minute => 12,
second => 47,
nanosecond => 500000000,
time_zone => 'Europe/Moscow',
);
#'Fri Jul 26 19:34:15 2013 +0200';
my $formatter =
DateTime::Format::Strptime->new( pattern => '%a %b %d %H:%M %Y %z' );
$dt->set_formatter($formatter);
my $n = 1;
for ( 1 .. 50 ) {
#inplace edit
edit_file { s/__NUMBER\d+__/__NUMBER${n}__/ }
$dir . '/pod2-ru/POD2-RU/scripts/get_pod_one_liners.md';
say "iteration №${n}";
say 'edit ok';
$r->run( add => '.' );
say 'add ok';
my $date = $dt->_stringify();
$r->run( commit => '-m', "my $n commit message", "--date=$date" );
say 'commit ok';
$dt->add( days => 1 );
$n++;
}
view raw 01_hack_git.pl hosted with ❤ by GitHub

Комментариев нет:

Отправить комментарий