diff options
| author | franck cuny <franck@lumberjaph.net> | 2010-09-13 16:14:34 +0200 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2010-09-13 16:14:34 +0200 |
| commit | 164f7f5b484f5236407904acf27de4a055503022 (patch) | |
| tree | ffd3579481dddd3a81fe9cc529139cc9b1b1eb82 /eg/github.pl | |
| parent | simple oauth middleware (diff) | |
| download | net-http-spore-164f7f5b484f5236407904acf27de4a055503022.tar.gz | |
some POD and examples
Diffstat (limited to '')
| -rw-r--r-- | eg/github.pl | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/eg/github.pl b/eg/github.pl new file mode 100644 index 0000000..4053d67 --- /dev/null +++ b/eg/github.pl @@ -0,0 +1,43 @@ +use strict; +use warnings; + +use Net::HTTP::Spore; +use Getopt::Long; + +use Config::GitLike::Git; +use Git::Repository; + +GetOptions( + 'spec=s' => \my $specification, + 'name=s' => \my $name, + 'desc=s' => \my $desc, +); + +print ">> creating repository $name on github\n"; + +my $c = Config::GitLike::Git->new(); +$c->load; + +my $login = $c->get(key => 'github.user'); +my $token = $c->get(key => 'github.token'); + +my $github = Net::HTTP::Spore->new_from_spec($specification); +$github->enable('Format::JSON'); +$github->enable( + 'Auth::Basic', + username => $login . '/token', + password => $token, +); + +my $remote = "git\@github.com:" . $login . "/" . $name . ".git"; + +my $res = $github->create_repo(format => 'json', payload => {name => $name, description => $desc}); + +print ">> repository $remote created\n"; + +my $r = Git::Repository->create(init => $name); +my @cmd = ('remote', 'add', 'origin', $remote); +$r->run(@cmd); + +print ">> repository cloned to $name\n"; +print ">> done!\n"; |
