· 7 years ago · Dec 02, 2017, 08:48 AM
1#!/usr/bin/perl -w
2use strict;
3
4use Net::GitHub;
5use Data::Dumper::Concise;
6
7my $oauth_token = qx(gpg --decrypt ../default.gpg 2>/dev/null);
8
9use Net::GitHub;
10my $gh = Net::GitHub->new( version => 3,
11 login => 'cjac',
12 access_token => $oauth_token );
13
14my @github_repos = $gh->repos->list;
15
16my ( @repo_list ) = split( $/, qx(ssh -p 29418 git.allseenalliance.org gerrit ls-projects) );
17
18foreach my $repo ( @repo_list ) {
19 next if $repo eq 'All-Users';
20
21 my $gerrit_url = 'ssh://git.allseenalliance.org:29418/' . ${repo};
22
23 my $github_repo_name = $repo;
24 $github_repo_name =~ s{/}{-}g;
25
26 my $repo_dir = "${github_repo_name}.git";
27
28 my $github_url = 'git@github.com:alljoyn/' . ${repo_dir};
29
30 qx{git clone --bare "${gerrit_url}" "${repo_dir}"};
31 chdir "${repo_dir}";
32
33 unless( grep /$github_repo/, @github_repos ){
34 my $rp = $gh->repos->create(
35 { "name" => $github_repo,
36 "description" => "mirror of ASA gerrit project $repo",
37 "homepage" => "$gerrit_url",
38 "license_template" => "apache-2.0",
39 "org" => "alljoyn",
40 } );
41 }
42
43 qx{git push --mirror "${github_url}"};
44 chdir "..";
45 qx{rm -rf "${repo_dir}"};
46
47 # exit;
48}