summaryrefslogtreecommitdiffstats
path: root/bin/git
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-03-29 10:58:21 -0500
committerJesse Luehrs <doy@tozt.net>2011-03-29 10:58:21 -0500
commit34772f03206b9280b6fa6064c6d173a5ba3f40ec (patch)
treee32d403154a4caea2abb29dbd9bd3bb1f9778e3a /bin/git
parent76613741160e1535c64863c9c9d15e29eb22334a (diff)
downloadconf-34772f03206b9280b6fa6064c6d173a5ba3f40ec.tar.gz
conf-34772f03206b9280b6fa6064c6d173a5ba3f40ec.zip
allow adding my own repos as remotes too
Diffstat (limited to 'bin/git')
-rwxr-xr-xbin/git/git-hub21
1 files changed, 16 insertions, 5 deletions
diff --git a/bin/git/git-hub b/bin/git/git-hub
index 6f2fe7d..f567420 100755
--- a/bin/git/git-hub
+++ b/bin/git/git-hub
@@ -5,6 +5,7 @@ use warnings;
package App::Git::Hub;
use File::pushd;
+use List::MoreUtils qw(any);
use Net::GitHub::V2;
sub git {
@@ -176,12 +177,22 @@ sub run_command_pullreq {
sub run_command_add {
my $self = shift;
- my ($owner, $repo) = @_;
- die "usage: git hub add <owner> <repo>"
- unless @_ == 2;
+ die "usage: git hub add [owner] <repo>"
+ unless @_ == 1 || @_ == 2;
+ my ($owner, $repo) = (@_ > 1 ? @_ : (undef, $_[0]));
+
+ my $remote;
+ if ($owner) {
+ $remote = $owner;
+ git "remote add $remote git://github.com/$owner/$repo.git";
+ }
+ else {
+ $owner = $self->user;
+ $remote = (any { /\borigin\b/ } git "remote") ? 'github' : 'origin';
+ git "remote add $remote git\@github.com:$owner/$repo.git";
+ }
- git "remote add $owner git://github.com/$owner/$repo.git";
- git "fetch $owner";
+ git "fetch $remote";
}
sub _github {