Skip to content

Commit

Permalink
Add create_github_repo tool
Browse files Browse the repository at this point in the history
  • Loading branch information
kentfredric committed Dec 21, 2013
1 parent 75aad7e commit 14e48d8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions create_github_repo.pl
@@ -0,0 +1,38 @@
#!/usr/bin/env perl
# FILENAME: create_github_repo.pl
# CREATED: 12/21/13 22:40:10 by Kent Fredric (kentnl) <kentfredric@gmail.com>
# ABSTRACT: Create a github repo for the current repository

use strict;
use warnings;
use utf8;
use Carp qw(croak);

sub _git_config {
my $key = shift;
chomp( my $value = `git config --get $key` );
croak "Unknown $key" unless $value;
return $value;
}

if ( not @ARGV == 2 ) {
die "$0 Repo-Name-Here \"Some Description\"";
}

my $github_user = _git_config('github.user');
my $github_token = _git_config('github.token');

use Net::GitHub;
my $gh = Net::GitHub->new( access_token => $github_token );
my $reponame = "git\@github.com:" . $github_user . "/" . $ARGV[0] . ".git";
print "Creating $reponame \n";

my $rp = $gh->repos->create(
{
name => $ARGV[0],
description => $ARGV[1],
}
);

system( 'git', 'remote', 'add', 'origin', $reponame );

0 comments on commit 14e48d8

Please sign in to comment.