-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgithub.pl
More file actions
executable file
·40 lines (34 loc) · 1.11 KB
/
github.pl
File metadata and controls
executable file
·40 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010000;
use Readonly;
use Carp;
use LWP::Simple qw{get};
#use LWP::Protocol::https;
#use Crypt::SSLeay;
use JSON;
#use Data::Dumper;
Readonly my $PROJECT_INDEX => 'https://api.github.com/users/pdurbin/repos';
Readonly my $LOCAL_GIT_DIR => "$ENV{HOME}/github/pdurbin";
Readonly my $GIT_CMD => $ARGV[0] || 'pull';
Readonly my $DOTDOT => q{..};
chdir $LOCAL_GIT_DIR or croak "Couldn't cd to $LOCAL_GIT_DIR";
my $project_list_json = get($PROJECT_INDEX);
if ( !$project_list_json ) {
croak "Couldn't download project index from $PROJECT_INDEX";
}
my $project_list_dd = from_json($project_list_json);
for my $repo ( @{$project_list_dd} ) {
my ($project_local) = $repo->{ssh_url} =~ qr{^git[@]github[.]com:pdurbin/(.*)[.]git$}ms;
next if $project_local eq 'todo.txt-touch';
next if $project_local eq 'rpms';
if ( chdir $project_local ) {
printf '%-31s', "$project_local... ";
system "git $GIT_CMD";
chdir $DOTDOT;
}
else {
print "Could not cd to $project_local. Clone with:\ngit clone $repo->{ssh_url}\n";
}
}