Created
November 29, 2017 22:29
-
-
Save cjac/4e6672c19ce1b95466d4e80c0f278ea1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/perl -w | |
use strict; | |
use Net::GitHub; | |
use Data::Dumper::Concise; | |
my $oauth_token = qx(gpg --decrypt ../default.gpg 2>/dev/null); | |
use Net::GitHub; | |
my $gh = Net::GitHub->new( version => 3, | |
login => 'cjac', | |
access_token => $oauth_token ); | |
my @github_repos = $gh->repos->list; | |
my ( @repo_list ) = split( $/, qx(ssh -p 29418 git.allseenalliance.org gerrit ls-projects) ); | |
foreach my $repo ( @repo_list ) { | |
next if $repo eq 'All-Users'; | |
my $gerrit_url = 'ssh://git.allseenalliance.org:29418/' . ${repo}; | |
my $github_repo_name = $repo; | |
$github_repo_name =~ s{/}{-}g; | |
my $repo_dir = "${github_repo_name}.git"; | |
my $github_url = '[email protected]:alljoyn/' . ${repo_dir}; | |
qx{git clone --bare "${gerrit_url}" "${repo_dir}"}; | |
chdir "${repo_dir}"; | |
unless( grep /$github_repo/, @github_repos ){ | |
my $rp = $gh->repos->create( | |
{ "name" => $github_repo, | |
"description" => "mirror of ASA gerrit project $repo", | |
"homepage" => "$gerrit_url", | |
"license_template" => "apache-2.0", | |
"org" => "alljoyn", | |
} ); | |
} | |
qx{git push --mirror "${github_url}"}; | |
chdir ".."; | |
qx{rm -rf "${repo_dir}"}; | |
# exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment