Changeset 19df400 in lab.git


Ignore:
Timestamp:
Aug 18, 2013 4:55:43 AM (11 years ago)
Author:
Ken-ichi Mito <mitty@…>
Branches:
master
Children:
6f31bfb
Parents:
b8d7413
Message:

remake accessors and create backup() method

  • repository list will flush with account() and repository()
  • backup() do backup
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/github/GitHubBackup.pm

    rb8d7413 r19df400  
    3333__PACKAGE__->mk_accessors( qw( 
    3434    directory 
    35     account 
    36     repository 
    3735)); 
    3836 
     
    4846     
    4947    return $class->SUPER::new($args); 
     48} 
     49 
     50sub account { 
     51    my $self = shift; 
     52    my $args = shift; 
     53     
     54    if (defined $args) { 
     55        $self->{repos} = undef; 
     56        $self->{account} = $args; 
     57    } 
     58     
     59    return $self->{account}; 
     60} 
     61 
     62sub repository { 
     63    my $self = shift; 
     64    my $args = shift; 
     65     
     66    if (defined $args) { 
     67        $self->{repos} = undef; 
     68        $self->{repository} = $args; 
     69    } 
     70     
     71    return $self->{repository}; 
    5072} 
    5173 
     
    92114} 
    93115 
     116sub backup { 
     117    my $self = shift; 
     118     
     119    foreach my $repos (@{$self->repos}) { 
     120        $repos->backup; 
     121    } 
     122     
     123    return $self; 
     124} 
     125 
    94126 
    95127package GitHubBackup::Repository; 
     
    128160    if (-d "$dir") { 
    129161        local $CWD = $dir; 
    130         print "fetch ", $self->{full_name}, "\n"; 
     162        print "fetch ", $dir, "\n"; 
    131163        Git::Repository->run(fetch => '--all'); 
    132164        return $self; 
    133165    } 
    134166     
    135     print "clone ", $self->{full_name}, "\n"; 
     167    print "clone ", $dir, "\n"; 
    136168    Git::Repository->run(clone => '--mirror' => $self->{clone_url} => $dir); 
    137169    return $self; 
     
    150182} 
    151183 
     184sub backup { 
     185    my $self = shift; 
     186     
     187    $self->clone_git; 
     188    $self->set_forks; 
     189    $self->clone_wiki; 
     190    $self->save_issues; 
     191     
     192    return $self; 
     193} 
    152194 
    153195 
Note: See TracChangeset for help on using the changeset viewer.