__PACKAGE__->mk_accessors( qw(
directory
- account
- repository
));
return $class->SUPER::new($args);
}
+sub account {
+ my $self = shift;
+ my $args = shift;
+
+ if (defined $args) {
+ $self->{repos} = undef;
+ $self->{account} = $args;
+ }
+
+ return $self->{account};
+}
+
+sub repository {
+ my $self = shift;
+ my $args = shift;
+
+ if (defined $args) {
+ $self->{repos} = undef;
+ $self->{repository} = $args;
+ }
+
+ return $self->{repository};
+}
+
sub repos {
my $self = shift;
return $self->{repos} if ($self->{repos});
return $self->{repos};
}
+sub backup {
+ my $self = shift;
+
+ foreach my $repos (@{$self->repos}) {
+ $repos->backup;
+ }
+
+ return $self;
+}
+
package GitHubBackup::Repository;
use base qw(Class::Accessor::Fast);
my $dir = $self->directory .'/'. $self->{full_name};
if (-d "$dir") {
local $CWD = $dir;
- print "fetch ", $self->{full_name}, "\n";
+ print "fetch ", $dir, "\n";
Git::Repository->run(fetch => '--all');
return $self;
}
- print "clone ", $self->{full_name}, "\n";
+ print "clone ", $dir, "\n";
Git::Repository->run(clone => '--mirror' => $self->{clone_url} => $dir);
return $self;
}
my $self = shift;
}
+sub backup {
+ my $self = shift;
+
+ $self->clone_git;
+ $self->set_forks;
+ $self->clone_wiki;
+ $self->save_issues;
+
+ return $self;
+}
1;