defunkt-github 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +6 -4
- data/README +8 -8
- data/bin/gh +5 -0
- data/commands/commands.rb +18 -12
- data/commands/helpers.rb +60 -11
- data/github-gem.gemspec +4 -4
- data/lib/github/command.rb +12 -41
- data/lib/github.rb +18 -2
- data/spec/ui_spec.rb +53 -5
- metadata +5 -2
data/Manifest
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
LICENSE
|
2
|
+
Manifest
|
3
|
+
README
|
4
|
+
bin/gh
|
1
5
|
bin/github
|
2
6
|
commands/commands.rb
|
3
7
|
commands/helpers.rb
|
4
|
-
|
8
|
+
github-gem.gemspec
|
5
9
|
lib/github/command.rb
|
10
|
+
lib/github/extensions.rb
|
6
11
|
lib/github/helper.rb
|
7
12
|
lib/github.rb
|
8
|
-
LICENSE
|
9
|
-
Manifest
|
10
|
-
README
|
11
13
|
spec/command_spec.rb
|
12
14
|
spec/extensions_spec.rb
|
13
15
|
spec/github_spec.rb
|
data/README
CHANGED
@@ -22,7 +22,7 @@ Pulling Upstream Changes
|
|
22
22
|
|
23
23
|
Let's say you just forked `github-gem` on GitHub from defunkt.
|
24
24
|
|
25
|
-
$
|
25
|
+
$ github clone git://github.com/YOU/github-gem.git
|
26
26
|
$ cd github-gem
|
27
27
|
$ github pull defunkt
|
28
28
|
|
@@ -36,8 +36,8 @@ checkout master` and then `git merge defunkt/master` to merge defunkt's changes
|
|
36
36
|
into your own master branch. In summary:
|
37
37
|
|
38
38
|
$ github pull defunkt
|
39
|
-
$
|
40
|
-
$
|
39
|
+
$ github checkout master
|
40
|
+
$ github merge defunkt/master
|
41
41
|
|
42
42
|
If you've already reviewed defunkt's changes and just want to merge them into your
|
43
43
|
master branch, use the `merge` flag:
|
@@ -67,12 +67,12 @@ Your local 'mojombo/master' branch is now at the exact same place as mojombo's
|
|
67
67
|
If mojombo's changes are good, you'll want to merge your 'master' (or another
|
68
68
|
branch) into those changes so you can retest post-integration:
|
69
69
|
|
70
|
-
$
|
70
|
+
$ github merge master
|
71
71
|
|
72
72
|
Test/analyze again and if everything is ok:
|
73
73
|
|
74
|
-
$
|
75
|
-
$
|
74
|
+
$ github checkout master
|
75
|
+
$ github merge mojombo/master
|
76
76
|
|
77
77
|
The latter command will be a fast-forward merge since you already did the
|
78
78
|
real merge previously.
|
@@ -111,12 +111,12 @@ which will show you something like this:
|
|
111
111
|
These are all the commits that you don't have in your current branch that have been
|
112
112
|
pushed to other forks of your project. If you want to incorporate them, you can use:
|
113
113
|
|
114
|
-
$
|
114
|
+
$ github cherry-pick ee013a
|
115
115
|
|
116
116
|
for example to apply that single patch to your branch. You can also merge a branch,
|
117
117
|
if you want all the changes introduced in another branch:
|
118
118
|
|
119
|
-
$
|
119
|
+
$ github merge jchris/gist
|
120
120
|
|
121
121
|
The next time you run the 'github network commits' command, you won't see any of the
|
122
122
|
patches you have cherry-picked or merged (or rebased). If you want to ignore a
|
data/bin/gh
ADDED
data/commands/commands.rb
CHANGED
@@ -39,13 +39,13 @@ command :network do |command, user|
|
|
39
39
|
when 'web'
|
40
40
|
helper.open helper.network_page_for(user)
|
41
41
|
when 'list'
|
42
|
-
data = get_network_data(user, options)
|
42
|
+
data = helper.get_network_data(user, options)
|
43
43
|
data['users'].each do |hsh|
|
44
44
|
puts [ hsh['name'].ljust(20), hsh['heads'].map {|a| a['name']}.uniq.join(', ') ].join(' ')
|
45
45
|
end
|
46
46
|
when 'fetch'
|
47
47
|
# fetch each remote we don't have
|
48
|
-
data = get_network_data(user, options)
|
48
|
+
data = helper.get_network_data(user, options)
|
49
49
|
data['users'].each do |hsh|
|
50
50
|
u = hsh['name']
|
51
51
|
GitHub.invoke(:track, u) unless helper.tracking?(u)
|
@@ -55,7 +55,7 @@ command :network do |command, user|
|
|
55
55
|
when 'commits'
|
56
56
|
# show commits we don't have yet
|
57
57
|
ids = []
|
58
|
-
data = get_network_data(user, options)
|
58
|
+
data = helper.get_network_data(user, options)
|
59
59
|
data['users'].each do |hsh|
|
60
60
|
u = hsh['name']
|
61
61
|
user_ids = hsh['heads'].map { |a| a['id'] }
|
@@ -69,14 +69,14 @@ command :network do |command, user|
|
|
69
69
|
ids += user_ids
|
70
70
|
end
|
71
71
|
ids.uniq!
|
72
|
-
|
72
|
+
|
73
73
|
# check that we have all these shas locally
|
74
|
-
|
74
|
+
|
75
75
|
local_heads = helper.local_heads
|
76
76
|
local_heads_not = local_heads.map { |a| "^#{a}"}
|
77
77
|
looking_for = (ids - local_heads) + local_heads_not
|
78
78
|
commits = helper.get_commits(looking_for)
|
79
|
-
|
79
|
+
|
80
80
|
cherry = []
|
81
81
|
ids.each do |id|
|
82
82
|
cherry += helper.get_cherry(id)
|
@@ -143,9 +143,9 @@ command :fetch do |user, branch|
|
|
143
143
|
user, branch = user.split("/", 2) if branch.nil?
|
144
144
|
branch ||= 'master'
|
145
145
|
GitHub.invoke(:track, user) unless helper.tracking?(user)
|
146
|
-
|
146
|
+
|
147
147
|
git "fetch #{user} #{branch}:refs/remotes/#{user}/#{branch}"
|
148
|
-
git_exec "checkout -b #{user}/#{branch} refs/remotes/#{user}/#{branch}"
|
148
|
+
git_exec "checkout -b #{user}/#{branch} refs/remotes/#{user}/#{branch}"
|
149
149
|
end
|
150
150
|
|
151
151
|
desc "Pull from a remote."
|
@@ -153,9 +153,14 @@ flags :merge => "Automatically merge remote's changes into your master."
|
|
153
153
|
command :pull do |user, branch|
|
154
154
|
die "Specify a user to pull from" if user.nil?
|
155
155
|
user, branch = user.split("/", 2) if branch.nil?
|
156
|
+
|
157
|
+
if !helper.network_members.include?(user)
|
158
|
+
git_exec "#{helper.argv.join(' ')}".strip
|
159
|
+
end
|
160
|
+
|
156
161
|
branch ||= 'master'
|
157
162
|
GitHub.invoke(:track, user) unless helper.tracking?(user)
|
158
|
-
|
163
|
+
|
159
164
|
if options[:merge]
|
160
165
|
git_exec "pull #{user} #{branch}"
|
161
166
|
else
|
@@ -169,16 +174,17 @@ desc "Clone a repo."
|
|
169
174
|
flags :ssh => "Clone using the git@github.com style url."
|
170
175
|
command :clone do |user, repo, dir|
|
171
176
|
die "Specify a user to pull from" if user.nil?
|
172
|
-
if user.include?
|
177
|
+
if user.include?('/') && !user.include?('@') && !user.include?(':')
|
173
178
|
die "Expected user/repo dir, given extra argument" if dir
|
174
179
|
(user, repo), dir = [user.split('/', 2), repo]
|
175
180
|
end
|
176
|
-
die "Specify a repo to pull from" if repo.nil?
|
177
181
|
|
178
182
|
if options[:ssh]
|
179
183
|
git_exec "clone git@github.com:#{user}/#{repo}.git" + (dir ? " #{dir}" : "")
|
180
|
-
|
184
|
+
elsif repo
|
181
185
|
git_exec "clone git://github.com/#{user}/#{repo}.git" + (dir ? " #{dir}" : "")
|
186
|
+
else
|
187
|
+
git_exec "#{helper.argv.join(' ')}".strip
|
182
188
|
end
|
183
189
|
end
|
184
190
|
|
data/commands/helpers.rb
CHANGED
@@ -53,7 +53,7 @@ helper :resolve_commits do |treeish|
|
|
53
53
|
else
|
54
54
|
# standard in
|
55
55
|
puts 'reading from stdin...'
|
56
|
-
commits = $stdin.read.split("\n")
|
56
|
+
commits = $stdin.read.split("\n")
|
57
57
|
end
|
58
58
|
commits.select { |a| a.size == 40 } # only the shas, not the ^SHAs
|
59
59
|
end
|
@@ -94,7 +94,7 @@ end
|
|
94
94
|
helper :print_commits do |cherries, commits, options|
|
95
95
|
ignores = ignore_sha_array
|
96
96
|
our_commits = cherries.map { |item| c = commits.assoc(item[1]); [item, c] if c }
|
97
|
-
|
97
|
+
|
98
98
|
case options[:sort]
|
99
99
|
when 'branch'
|
100
100
|
our_commits.sort! { |a, b| a[0][2] <=> b[0][2] }
|
@@ -103,7 +103,7 @@ helper :print_commits do |cherries, commits, options|
|
|
103
103
|
else
|
104
104
|
our_commits.sort! { |a, b| Date.parse(a[1][4]) <=> Date.parse(b[1][4]) }
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
shown_commits = {}
|
108
108
|
before = Date.parse(options[:before]) if options[:before] rescue puts 'cant parse before date'
|
109
109
|
after = Date.parse(options[:after]) if options[:after] rescue puts 'cant parse after date'
|
@@ -114,14 +114,14 @@ helper :print_commits do |cherries, commits, options|
|
|
114
114
|
ref_name = ref_name.gsub('remotes/', '')
|
115
115
|
if status == '+' && commit
|
116
116
|
next if options[:author] && !commit[1].match(Regexp.new(options[:author]))
|
117
|
-
next if options[:before] && before && (before < Date.parse(commit[4]))
|
118
|
-
next if options[:after] && after && (after > Date.parse(commit[4]))
|
117
|
+
next if options[:before] && before && (before < Date.parse(commit[4]))
|
118
|
+
next if options[:after] && after && (after > Date.parse(commit[4]))
|
119
119
|
next if options[:applies] && !applies_cleanly(sha)
|
120
120
|
if options[:shas]
|
121
121
|
puts sha
|
122
122
|
else
|
123
123
|
common = options[:common] ? get_common(sha) : ''
|
124
|
-
puts [sha[0,6], ref_name.ljust(25), commit[1][0,20].ljust(21),
|
124
|
+
puts [sha[0,6], ref_name.ljust(25), commit[1][0,20].ljust(21),
|
125
125
|
commit[2][0, 36].ljust(38), commit[3], common].join(" ")
|
126
126
|
end
|
127
127
|
end
|
@@ -232,17 +232,17 @@ You have to provide a command :
|
|
232
232
|
|
233
233
|
web [user] - opens your web browser to the network graph page for this
|
234
234
|
project, or for the graph page for [user] if provided
|
235
|
-
|
235
|
+
|
236
236
|
list - shows the projects in your network that have commits
|
237
|
-
that you have not pulled in yet, and branch names
|
238
|
-
|
237
|
+
that you have not pulled in yet, and branch names
|
238
|
+
|
239
239
|
fetch - adds all projects in your network as remotes and fetches
|
240
240
|
any objects from them that you don't have yet
|
241
|
-
|
241
|
+
|
242
242
|
commits - will show you a list of all commits in your network that
|
243
243
|
you have not ignored or have not merged or cherry-picked.
|
244
244
|
This will automatically fetch objects you don't have yet.
|
245
|
-
|
245
|
+
|
246
246
|
--project (user/branch) - only show projects that match string
|
247
247
|
--author (email) - only show projects that match string
|
248
248
|
--after (date) - only show commits after date
|
@@ -268,3 +268,52 @@ applied or ignored yet (see 'github ignore'). Some things you might want to do:
|
|
268
268
|
"
|
269
269
|
end
|
270
270
|
|
271
|
+
helper :get_network_data do |user, options|
|
272
|
+
if options[:cache] && has_cache?
|
273
|
+
return get_cache
|
274
|
+
end
|
275
|
+
|
276
|
+
if cache_expired? || options[:nocache] || !has_cache?
|
277
|
+
return cache_data(user)
|
278
|
+
else
|
279
|
+
return get_cache
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
helper :network_members do
|
284
|
+
get_network_data(owner, {})['users'].map do |hash|
|
285
|
+
hash['name']
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
helper :network_cache_path do
|
290
|
+
dir = `git rev-parse --git-dir`.chomp
|
291
|
+
File.join(dir, 'network-cache')
|
292
|
+
end
|
293
|
+
|
294
|
+
helper :cache_data do |user|
|
295
|
+
raw_data = Kernel.open(network_meta_for(user)).read
|
296
|
+
File.open( network_cache_path, 'w' ) do |out|
|
297
|
+
out.write(raw_data)
|
298
|
+
end
|
299
|
+
data = JSON.parse(raw_data)
|
300
|
+
end
|
301
|
+
|
302
|
+
helper :cache_expired? do
|
303
|
+
return true if !has_cache?
|
304
|
+
age = Time.now - File.stat(network_cache_path).mtime
|
305
|
+
return true if age > (60 * 60) # 1 hour
|
306
|
+
false
|
307
|
+
end
|
308
|
+
|
309
|
+
helper :has_cache? do
|
310
|
+
File.file?(network_cache_path)
|
311
|
+
end
|
312
|
+
|
313
|
+
helper :get_cache do
|
314
|
+
JSON.parse(File.read(network_cache_path))
|
315
|
+
end
|
316
|
+
|
317
|
+
helper :argv do
|
318
|
+
GitHub.original_args
|
319
|
+
end
|
data/github-gem.gemspec
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{github}
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.3.0"
|
4
4
|
|
5
5
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Chris Wanstrath, Kevin Ballard, Scott Chacon"]
|
9
9
|
s.date = %q{2008-05-18}
|
10
|
-
s.default_executable = %q{
|
10
|
+
s.default_executable = %q{gh}
|
11
11
|
s.description = %q{The official `github` command line helper for simplifying your GitHub experience.}
|
12
12
|
s.email = %q{chris@ozmm.org}
|
13
|
-
s.executables = ["github"]
|
14
|
-
s.extra_rdoc_files = ["bin/github", "lib/github/extensions.rb", "lib/github/command.rb", "lib/github/helper.rb", "lib/github.rb", "LICENSE", "README"]
|
13
|
+
s.executables = ["github", "gh"]
|
14
|
+
s.extra_rdoc_files = ["bin/github", "bin/gh", "lib/github/extensions.rb", "lib/github/command.rb", "lib/github/helper.rb", "lib/github.rb", "LICENSE", "README"]
|
15
15
|
s.files = ["bin/github", "commands/commands.rb", "commands/helpers.rb", "lib/github/extensions.rb", "lib/github/command.rb", "lib/github/helper.rb", "lib/github.rb", "LICENSE", "Manifest", "README", "spec/command_spec.rb", "spec/extensions_spec.rb", "spec/github_spec.rb", "spec/helper_spec.rb", "spec/spec_helper.rb", "spec/ui_spec.rb", "spec/windoze_spec.rb", "github-gem.gemspec"]
|
16
16
|
s.has_rdoc = true
|
17
17
|
s.homepage = %q{http://github.com/}
|
data/lib/github/command.rb
CHANGED
@@ -20,7 +20,7 @@ module GitHub
|
|
20
20
|
args << nil while args.size < arity
|
21
21
|
send :command, *args
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def helper
|
25
25
|
@helper ||= Helper.new
|
26
26
|
end
|
@@ -47,45 +47,6 @@ module GitHub
|
|
47
47
|
Shell.new(*command).run
|
48
48
|
end
|
49
49
|
|
50
|
-
def get_network_data(user, options)
|
51
|
-
if options[:cache] && has_cache?
|
52
|
-
return get_cache
|
53
|
-
end
|
54
|
-
if cache_expired? || options[:nocache] || !has_cache?
|
55
|
-
return cache_data(user)
|
56
|
-
else
|
57
|
-
return get_cache
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def network_cache_path
|
62
|
-
dir = `git rev-parse --git-dir`.chomp
|
63
|
-
File.join(dir, 'network-cache')
|
64
|
-
end
|
65
|
-
|
66
|
-
def cache_data(user)
|
67
|
-
raw_data = open(helper.network_meta_for(user)).read
|
68
|
-
File.open( network_cache_path, 'w' ) do |out|
|
69
|
-
out.write(raw_data)
|
70
|
-
end
|
71
|
-
data = JSON.parse(raw_data)
|
72
|
-
end
|
73
|
-
|
74
|
-
def cache_expired?
|
75
|
-
return true if !has_cache?
|
76
|
-
age = Time.now - File.stat(network_cache_path).mtime
|
77
|
-
return true if age > (60 * 60) # 1 hour
|
78
|
-
false
|
79
|
-
end
|
80
|
-
|
81
|
-
def has_cache?
|
82
|
-
File.file?(network_cache_path)
|
83
|
-
end
|
84
|
-
|
85
|
-
def get_cache
|
86
|
-
JSON.parse(File.read(network_cache_path))
|
87
|
-
end
|
88
|
-
|
89
50
|
def die(message)
|
90
51
|
puts "=> #{message}"
|
91
52
|
exit!
|
@@ -99,7 +60,7 @@ module GitHub
|
|
99
60
|
def run
|
100
61
|
GitHub.debug "sh: #{command}"
|
101
62
|
_, out, err = Open3.popen3(*@command)
|
102
|
-
|
63
|
+
|
103
64
|
out = out.read.strip
|
104
65
|
err = err.read.strip
|
105
66
|
|
@@ -123,4 +84,14 @@ module GitHub
|
|
123
84
|
end
|
124
85
|
end
|
125
86
|
end
|
87
|
+
|
88
|
+
class GitCommand < Command
|
89
|
+
def initialize(name)
|
90
|
+
@name = name
|
91
|
+
end
|
92
|
+
|
93
|
+
def command(*args)
|
94
|
+
git_exec *[ @name, args ]
|
95
|
+
end
|
96
|
+
end
|
126
97
|
end
|
data/lib/github.rb
CHANGED
@@ -13,7 +13,7 @@ require 'yaml'
|
|
13
13
|
# $ github <command> <args>
|
14
14
|
#
|
15
15
|
# GitHub.command <command> do |*args|
|
16
|
-
# whatever
|
16
|
+
# whatever
|
17
17
|
# end
|
18
18
|
#
|
19
19
|
# We'll probably want to use the `choice` gem for concise, tasty DSL
|
@@ -49,6 +49,7 @@ module GitHub
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def activate(args)
|
52
|
+
@@original_args = args.clone
|
52
53
|
@options = parse_options(args)
|
53
54
|
@debug = @options[:debug]
|
54
55
|
load 'helpers.rb'
|
@@ -57,11 +58,16 @@ module GitHub
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def invoke(command, *args)
|
60
|
-
block =
|
61
|
+
block = find_command(command)
|
61
62
|
debug "Invoking `#{command}`"
|
62
63
|
block.call(*args)
|
63
64
|
end
|
64
65
|
|
66
|
+
def find_command(name)
|
67
|
+
name = name.to_s
|
68
|
+
commands[name] || GitCommand.new(name) || commands['default']
|
69
|
+
end
|
70
|
+
|
65
71
|
def commands
|
66
72
|
@commands ||= {}
|
67
73
|
end
|
@@ -78,6 +84,10 @@ module GitHub
|
|
78
84
|
@options
|
79
85
|
end
|
80
86
|
|
87
|
+
def original_args
|
88
|
+
@@original_args ||= []
|
89
|
+
end
|
90
|
+
|
81
91
|
def parse_options(args)
|
82
92
|
idx = 0
|
83
93
|
args.clone.inject({}) do |memo, arg|
|
@@ -128,3 +138,9 @@ GitHub.command :default do
|
|
128
138
|
end
|
129
139
|
puts
|
130
140
|
end
|
141
|
+
|
142
|
+
GitHub.commands[''] = GitHub.commands['default']
|
143
|
+
GitHub.commands['-h'] = GitHub.commands['default']
|
144
|
+
GitHub.commands['--help'] = GitHub.commands['default']
|
145
|
+
GitHub.commands['-help'] = GitHub.commands['default']
|
146
|
+
GitHub.commands['help'] = GitHub.commands['default']
|
data/spec/ui_spec.rb
CHANGED
@@ -167,6 +167,7 @@ EOF
|
|
167
167
|
|
168
168
|
specify "pull defunkt should start tracking defunkt if they're not already tracked" do
|
169
169
|
running :pull, "defunkt" do
|
170
|
+
mock_members 'defunkt'
|
170
171
|
setup_remote(:origin, :user => "user", :ssh => true)
|
171
172
|
setup_remote(:external, :url => "home:/path/to/project.git")
|
172
173
|
GitHub.should_receive(:invoke).with(:track, "defunkt").and_return { raise "Tracked" }
|
@@ -176,6 +177,7 @@ EOF
|
|
176
177
|
|
177
178
|
specify "pull defunkt should create defunkt/master and pull from the defunkt remote" do
|
178
179
|
running :pull, "defunkt" do
|
180
|
+
mock_members 'defunkt'
|
179
181
|
setup_remote(:defunkt)
|
180
182
|
@command.should_receive(:git).with("checkout -b defunkt/master").ordered.and_return do
|
181
183
|
mock("checkout -b defunkt/master").tap { |m| m.stub!(:error?) }
|
@@ -187,6 +189,7 @@ EOF
|
|
187
189
|
|
188
190
|
specify "pull defunkt should switch to pre-existing defunkt/master and pull from the defunkt remote" do
|
189
191
|
running :pull, "defunkt" do
|
192
|
+
mock_members 'defunkt'
|
190
193
|
setup_remote(:defunkt)
|
191
194
|
@command.should_receive(:git).with("checkout -b defunkt/master").ordered.and_return do
|
192
195
|
mock("checkout -b defunkt/master").tap { |m| m.should_receive(:error?) { true } }
|
@@ -199,6 +202,7 @@ EOF
|
|
199
202
|
|
200
203
|
specify "pull defunkt wip should create defunkt/wip and pull from wip branch on defunkt remote" do
|
201
204
|
running :pull, "defunkt", "wip" do
|
205
|
+
mock_members 'defunkt'
|
202
206
|
setup_remote(:defunkt)
|
203
207
|
@command.should_receive(:git).with("checkout -b defunkt/wip").ordered.and_return do
|
204
208
|
mock("checkout -b defunkt/wip").tap { |m| m.stub!(:error?) }
|
@@ -210,6 +214,7 @@ EOF
|
|
210
214
|
|
211
215
|
specify "pull defunkt/wip should switch to pre-existing defunkt/wip and pull from wip branch on defunkt remote" do
|
212
216
|
running :pull, "defunkt/wip" do
|
217
|
+
mock_members 'defunkt'
|
213
218
|
setup_remote(:defunkt)
|
214
219
|
@command.should_receive(:git).with("checkout -b defunkt/wip").ordered.and_return do
|
215
220
|
mock("checkout -b defunkt/wip").tap { |m| m.should_receive(:error?) { true } }
|
@@ -222,11 +227,26 @@ EOF
|
|
222
227
|
|
223
228
|
specify "pull --merge defunkt should pull from defunkt remote into current branch" do
|
224
229
|
running :pull, "--merge", "defunkt" do
|
230
|
+
mock_members 'defunkt'
|
225
231
|
setup_remote(:defunkt)
|
226
232
|
@command.should_receive(:git_exec).with("pull defunkt master")
|
227
233
|
end
|
228
234
|
end
|
229
235
|
|
236
|
+
specify "pull falls through for non-recognized commands" do
|
237
|
+
running :pull, 'remote' do
|
238
|
+
mock_members 'defunkt'
|
239
|
+
@command.should_receive(:git_exec).with("pull remote")
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
specify "pull passes along args when falling through" do
|
244
|
+
running :pull, 'remote', '--stat' do
|
245
|
+
mock_members 'defunkt'
|
246
|
+
@command.should_receive(:git_exec).with("pull remote --stat")
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
230
250
|
# -- clone --
|
231
251
|
specify "clone should die with no args" do
|
232
252
|
running :clone do
|
@@ -235,10 +255,9 @@ EOF
|
|
235
255
|
end
|
236
256
|
end
|
237
257
|
|
238
|
-
specify "clone should
|
239
|
-
running :clone, "
|
240
|
-
@command.should_receive(:
|
241
|
-
self.should raise_error("Died")
|
258
|
+
specify "clone should fall through with just one arg" do
|
259
|
+
running :clone, "git://git.kernel.org/linux.git" do
|
260
|
+
@command.should_receive(:git_exec).with("clone git://git.kernel.org/linux.git")
|
242
261
|
end
|
243
262
|
end
|
244
263
|
|
@@ -248,6 +267,12 @@ EOF
|
|
248
267
|
end
|
249
268
|
end
|
250
269
|
|
270
|
+
specify "clone defunkt/github-gem should clone the repo" do
|
271
|
+
running :clone, "defunkt/github-gem" do
|
272
|
+
@command.should_receive(:git_exec).with("clone git://github.com/defunkt/github-gem.git")
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
251
276
|
specify "clone --ssh defunkt github-gem should clone the repo using the private URL" do
|
252
277
|
running :clone, "--ssh", "defunkt", "github-gem" do
|
253
278
|
@command.should_receive(:git_exec).with("clone git@github.com:defunkt/github-gem.git")
|
@@ -260,6 +285,12 @@ EOF
|
|
260
285
|
end
|
261
286
|
end
|
262
287
|
|
288
|
+
specify "clone defunkt/github-gem repo should clone the repo into the dir 'repo'" do
|
289
|
+
running :clone, "defunkt/github-gem", "repo" do
|
290
|
+
@command.should_receive(:git_exec).with("clone git://github.com/defunkt/github-gem.git repo")
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
263
294
|
specify "clone --ssh defunkt github-gem repo should clone the repo using the private URL into the dir 'repo'" do
|
264
295
|
running :clone, "--ssh", "defunkt", "github-gem", "repo" do
|
265
296
|
@command.should_receive(:git_exec).with("clone git@github.com:defunkt/github-gem.git repo")
|
@@ -318,6 +349,19 @@ EOF
|
|
318
349
|
end
|
319
350
|
end
|
320
351
|
|
352
|
+
# -- fallthrough --
|
353
|
+
specify "should fall through to actual git commands" do
|
354
|
+
running :commit do
|
355
|
+
@command.should_receive(:git_exec).with("commit")
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
specify "should pass along arguments when falling through" do
|
360
|
+
running :commit, '-a', '-m', 'yo mama' do
|
361
|
+
@command.should_receive(:git_exec).with("commit -a -m 'yo mama'")
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
321
365
|
# -- default --
|
322
366
|
specify "should print the default message" do
|
323
367
|
running :default do
|
@@ -357,7 +401,7 @@ EOF
|
|
357
401
|
|
358
402
|
def initialize(parent, cmd, *args, &block)
|
359
403
|
@cmd_name = cmd.to_s
|
360
|
-
@command = GitHub.
|
404
|
+
@command = GitHub.find_command(cmd)
|
361
405
|
@helper = @command.helper
|
362
406
|
@args = args
|
363
407
|
@block = block
|
@@ -409,6 +453,10 @@ EOF
|
|
409
453
|
@helper.should_receive(:remotes).any_number_of_times.and_return(@remotes)
|
410
454
|
end
|
411
455
|
|
456
|
+
def mock_members(members)
|
457
|
+
@helper.should_receive(:network_members).any_number_of_times.and_return(members)
|
458
|
+
end
|
459
|
+
|
412
460
|
def should(result)
|
413
461
|
@expected_result = [:should, result]
|
414
462
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defunkt-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath, Kevin Ballard, Scott Chacon
|
@@ -10,17 +10,19 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
|
12
12
|
date: 2008-05-18 00:00:00 -07:00
|
13
|
-
default_executable:
|
13
|
+
default_executable: gh
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: The official `github` command line helper for simplifying your GitHub experience.
|
17
17
|
email: chris@ozmm.org
|
18
18
|
executables:
|
19
19
|
- github
|
20
|
+
- gh
|
20
21
|
extensions: []
|
21
22
|
|
22
23
|
extra_rdoc_files:
|
23
24
|
- bin/github
|
25
|
+
- bin/gh
|
24
26
|
- lib/github/extensions.rb
|
25
27
|
- lib/github/command.rb
|
26
28
|
- lib/github/helper.rb
|
@@ -46,6 +48,7 @@ files:
|
|
46
48
|
- spec/ui_spec.rb
|
47
49
|
- spec/windoze_spec.rb
|
48
50
|
- github-gem.gemspec
|
51
|
+
- bin/gh
|
49
52
|
has_rdoc: true
|
50
53
|
homepage: http://github.com/
|
51
54
|
post_install_message:
|