forked from pdurbin/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 51e80dd
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env perl | ||
use strict; | ||
use warnings; | ||
use 5.010000; | ||
use Readonly; | ||
use Carp; | ||
use LWP::Simple qw{get}; | ||
use YAML; | ||
#use Data::Dumper; | ||
|
||
Readonly my $GIT_SERVER => 'git.greptilian.com'; | ||
Readonly my $GIT_USER => 'pdurbin'; | ||
Readonly my $PROJECT_INDEX => "http://$GIT_SERVER/?a=project_index"; | ||
Readonly my $PROJECT_DIR => '/var/lib/git'; | ||
Readonly my $LOCAL_GIT_DIR => "$ENV{HOME}/gr"; | ||
Readonly my $GIT_CLONE_PATH => "$GIT_SERVER:$PROJECT_DIR"; | ||
Readonly my $DOTDOT => q{..}; | ||
Readonly my $FILES_NON_DOT => q{*}; | ||
Readonly my $DESCRIPTIONS => "http://$GIT_SERVER/?p=wiki.git;a=blob_plain;f=greptilian.com/git/repos.mdwn;hb=HEAD"; | ||
|
||
chdir($LOCAL_GIT_DIR) or croak "Couldn't cd to $LOCAL_GIT_DIR"; | ||
|
||
my $project_list = get($PROJECT_INDEX); | ||
|
||
if ( !$project_list ) { | ||
croak "Couldn't download project index from $PROJECT_INDEX"; | ||
} | ||
|
||
my @projects = split( /\n/, $project_list ); | ||
s{^\s+|\s+$}{}g for @projects; | ||
|
||
my $descriptions_yaml = get($DESCRIPTIONS); | ||
|
||
if ( !$descriptions_yaml ) { | ||
croak "Couldn't download git repo descriptions_yaml from $DESCRIPTIONS"; | ||
} | ||
|
||
my $proj_descriptions = Load($descriptions_yaml); | ||
|
||
for my $repo ( sort keys %{$proj_descriptions} ) { | ||
carp "No description for $repo at $DESCRIPTIONS" unless ($repo ~~ @projects); | ||
} | ||
|
||
for my $project_bare (sort @projects) { | ||
carp "No description for $project_bare at $DESCRIPTIONS" unless ${$proj_descriptions}{$project_bare}; | ||
my ($project_local) = $project_bare =~ /^(.*?)[.]git/; | ||
if ( chdir($project_local) ) { | ||
printf( '%-30s', "$project_local... " ); | ||
system('git pull'); | ||
chdir($DOTDOT); | ||
} | ||
else { | ||
"Could not cd to $project_local. Clone with:\ngit clone $GIT_USER\@$GIT_CLONE_PATH/$project_bare\n"; | ||
} | ||
} |