mygit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +59 -0
- data/bin/mygit +72 -0
- metadata +66 -0
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
mygit
|
2
|
+
=====
|
3
|
+
|
4
|
+
A wrapper around some GitHub API commands to allow quicker access to do stuff.
|
5
|
+
|
6
|
+
|
7
|
+
Setup
|
8
|
+
-----
|
9
|
+
|
10
|
+
Put config file where I can find it :-
|
11
|
+
|
12
|
+
cp .mygit-example ~/.mygit
|
13
|
+
|
14
|
+
And then edit it to add your details
|
15
|
+
|
16
|
+
Setup a symlink to a directory in your path (I have ~/bin in mine)
|
17
|
+
|
18
|
+
ln -s <full-path>/mygit/mygit ~/bin/mygit
|
19
|
+
|
20
|
+
(Of course you can alias it to anything you like!)
|
21
|
+
|
22
|
+
|
23
|
+
Usage
|
24
|
+
-----
|
25
|
+
|
26
|
+
Git a list of all repos :-
|
27
|
+
|
28
|
+
$ mygit list
|
29
|
+
...
|
30
|
+
urlybird git@github.com:globaldev/urlybird.git
|
31
|
+
...
|
32
|
+
|
33
|
+
|
34
|
+
Find info on a repo :-
|
35
|
+
|
36
|
+
$ mygit find urlybird
|
37
|
+
{"language"=>"Ruby",
|
38
|
+
"description"=>"Fetches all your URIs in one fell swoop.",
|
39
|
+
"ssh_url"=>"git@github.com:globaldev/urlybird.git",
|
40
|
+
"html_url"=>"https://github.com/globaldev/urlybird",
|
41
|
+
"pushed_at"=>"2012-05-30T11:13:54Z",
|
42
|
+
"created_at"=>"2012-05-16T08:19:38Z",
|
43
|
+
....
|
44
|
+
(tons more)
|
45
|
+
|
46
|
+
Clone a repo by name :-
|
47
|
+
|
48
|
+
$ mygit clone urlybird
|
49
|
+
Cloning into 'urlybird'...
|
50
|
+
...
|
51
|
+
|
52
|
+
Open the GitHub project page :-
|
53
|
+
|
54
|
+
$ mygit open urlybird
|
55
|
+
|
56
|
+
or from within the repo
|
57
|
+
|
58
|
+
$ mygit open
|
59
|
+
|
data/bin/mygit
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby -wKU
|
2
|
+
# curl -u "github@ianvaughan.co.uk:password" https://api.github.com/orgs/globaldev/repos
|
3
|
+
|
4
|
+
require 'httparty'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
class GitHub
|
8
|
+
include HTTParty
|
9
|
+
base_uri 'https://api.github.com'
|
10
|
+
|
11
|
+
def initialize(u, p)
|
12
|
+
@auth = {:username => u, :password => p}
|
13
|
+
end
|
14
|
+
|
15
|
+
def repos repo
|
16
|
+
self.class.get("/orgs/#{repo}/repos", {:basic_auth => @auth})
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class Access
|
22
|
+
def initialize
|
23
|
+
conf = YAML.load_file File.expand_path '~/.mygit'
|
24
|
+
@repo = GitHub.new(conf['user'], conf['pass']).repos(conf['repo'])
|
25
|
+
end
|
26
|
+
|
27
|
+
def keys
|
28
|
+
puts @repo.first.each_key { |k| puts k }
|
29
|
+
end
|
30
|
+
|
31
|
+
def list
|
32
|
+
@repo.each do |r|
|
33
|
+
spaces = ' ' * (30 - r['name'].size)
|
34
|
+
puts "#{r['name']} #{spaces} #{r['ssh_url']}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def find name
|
39
|
+
found = nil
|
40
|
+
@repo.each do |r|
|
41
|
+
found = r if r['name'] == name
|
42
|
+
end
|
43
|
+
found
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# git clone name -> looks up git@ ssh, then cd
|
48
|
+
|
49
|
+
access = Access.new
|
50
|
+
|
51
|
+
cmd = ARGV.shift
|
52
|
+
case cmd
|
53
|
+
when 'list' # dumps a list of all repos found
|
54
|
+
access.list
|
55
|
+
when 'find' # find a repo by name
|
56
|
+
pp access.find ARGV.shift
|
57
|
+
when 'clone' # clone a repo by name
|
58
|
+
p = access.find ARGV.shift
|
59
|
+
cmd = "git clone #{p['ssh_url']}"
|
60
|
+
system cmd
|
61
|
+
when 'open' # Opens either the current pwd, or a supplied project, GitHub project page in a browser
|
62
|
+
opt = ARGV.shift
|
63
|
+
opt = File.basename(Dir.getwd) if opt.nil?
|
64
|
+
p = access.find opt
|
65
|
+
system "open #{p['html_url']}"
|
66
|
+
else
|
67
|
+
puts 'Unknown or no command given! Options are :-'
|
68
|
+
File.open(__FILE__).each_line do |line|
|
69
|
+
puts " " + line.sub('when','').sub('#', '->').gsub('\'','') if line.include? 'when'
|
70
|
+
break if line.include? 'else'
|
71
|
+
end
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mygit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ian Vaughan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Allows you to do cool things from the CLI with GitHub
|
31
|
+
email:
|
32
|
+
- mygit@ianvaughan.co.uk
|
33
|
+
executables:
|
34
|
+
- mygit
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- README.md
|
39
|
+
- bin/mygit
|
40
|
+
homepage: http://github.com/ianvaughan/mygit
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.9'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.8.24
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: Some CLI commands to talk to GitHub
|
65
|
+
test_files: []
|
66
|
+
has_rdoc:
|