nex3-github 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +18 -0
- data/Manifest +17 -0
- data/README +53 -0
- data/bin/github +5 -0
- data/commands/commands.rb +66 -0
- data/commands/helpers.rb +94 -0
- data/lib/github/command.rb +87 -0
- data/lib/github/helper.rb +4 -0
- data/lib/github.rb +99 -0
- data/spec/command_spec.rb +0 -0
- data/spec/helpers/owner_spec.rb +12 -0
- data/spec/helpers/project_spec.rb +24 -0
- data/spec/helpers/public_url_for_spec.rb +12 -0
- data/spec/helpers/repo_for_spec.rb +12 -0
- data/spec/helpers/user_and_repo_from_spec.rb +37 -0
- data/spec/helpers/user_for_spec.rb +12 -0
- data/spec/spec_helper.rb +9 -0
- metadata +80 -0
data/LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2008 Chris Wanstrath
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
7
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
8
|
+
subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
15
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
16
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
bin/github
|
2
|
+
commands/commands.rb
|
3
|
+
commands/helpers.rb
|
4
|
+
lib/github/command.rb
|
5
|
+
lib/github/helper.rb
|
6
|
+
lib/github.rb
|
7
|
+
LICENSE
|
8
|
+
README
|
9
|
+
spec/command_spec.rb
|
10
|
+
spec/helpers/owner_spec.rb
|
11
|
+
spec/helpers/project_spec.rb
|
12
|
+
spec/helpers/public_url_for_spec.rb
|
13
|
+
spec/helpers/repo_for_spec.rb
|
14
|
+
spec/helpers/user_and_repo_from_spec.rb
|
15
|
+
spec/helpers/user_for_spec.rb
|
16
|
+
spec/spec_helper.rb
|
17
|
+
Manifest
|
data/README
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
The GitHub Gem
|
2
|
+
=============
|
3
|
+
|
4
|
+
This gem'll work hand-in-hand with GitHub's API to help you out.
|
5
|
+
|
6
|
+
Catch us in the #github room on freenode if you want to get involved. Or just fork and send a pull request.
|
7
|
+
|
8
|
+
===========
|
9
|
+
Getting started
|
10
|
+
===========
|
11
|
+
|
12
|
+
$ gem install github
|
13
|
+
|
14
|
+
Run it:
|
15
|
+
|
16
|
+
$ github <command> <args>
|
17
|
+
|
18
|
+
|
19
|
+
=============
|
20
|
+
Pulling Changes
|
21
|
+
=============
|
22
|
+
|
23
|
+
Let's say you just forked `github-gem` on GitHub from defunkt.
|
24
|
+
|
25
|
+
$ git clone git://github.com/YOU/github-gem.git
|
26
|
+
$ cd github-gem
|
27
|
+
$ github pull defunkt
|
28
|
+
|
29
|
+
This will setup a remote and branch for defunkt's repository at master.
|
30
|
+
In this case, a 'defunkt/master' branch.
|
31
|
+
|
32
|
+
If defunkt makes some changes you want, simply `github pull defunkt`. This will
|
33
|
+
leave you in the 'defunkt/master' branch after pulling changes from defunkt's
|
34
|
+
remote. After confirming that defunkt's changes were what you wanted, run `git
|
35
|
+
checkout master` and then `git merge defunkt/master` to merge defunkt's changes
|
36
|
+
into your own master branch. In summary:
|
37
|
+
|
38
|
+
$ github pull defunkt
|
39
|
+
$ git checkout master
|
40
|
+
$ git merge defunkt/master
|
41
|
+
|
42
|
+
If you've already reviewed defunkt's changes and just want to merge them into your
|
43
|
+
master branch, use the `merge` flag:
|
44
|
+
|
45
|
+
$ github pull --merge defunkt
|
46
|
+
|
47
|
+
==========
|
48
|
+
Contributors
|
49
|
+
==========
|
50
|
+
|
51
|
+
- defunkt
|
52
|
+
- maddox
|
53
|
+
- halorgium
|
data/bin/github
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
GitHub.register :helper do |name, comma_args|
|
2
|
+
comma_args ||= ''
|
3
|
+
puts helper.send(name, comma_args.split(/,/))
|
4
|
+
end
|
5
|
+
|
6
|
+
GitHub.describe :home => "Open this repo's master branch in a web browser."
|
7
|
+
GitHub.register :home do
|
8
|
+
if helper.project
|
9
|
+
exec "#{helper.open} #{helper.homepage_for(helper.owner, 'master')}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
GitHub.describe :browse => "Open this repo in a web browser."
|
14
|
+
GitHub.register :browse do
|
15
|
+
if helper.project
|
16
|
+
exec "#{helper.open} #{helper.homepage_for(helper.branch_user, helper.branch_name)}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
GitHub.describe :info => "Info about this project."
|
21
|
+
GitHub.register :info do
|
22
|
+
puts "== Info for #{helper.project}"
|
23
|
+
puts "You are #{helper.owner}"
|
24
|
+
puts "Currently tracking: "
|
25
|
+
helper.tracking.each do |(name,user_or_url)|
|
26
|
+
puts " - #{user_or_url} (as #{name})"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
GitHub.describe :track => "Track another user's repository."
|
31
|
+
GitHub.register :track do |user|
|
32
|
+
die "Specify a user to track" if user.nil?
|
33
|
+
die "Already tracking #{user}" if helper.tracking?(user)
|
34
|
+
|
35
|
+
git "remote add #{user} #{helper.public_url_for(user)}"
|
36
|
+
end
|
37
|
+
|
38
|
+
GitHub.describe :pull => "Pull from a remote. Pass --merge to automatically merge remote's changes into your master."
|
39
|
+
GitHub.register :pull do |user, branch|
|
40
|
+
die "Specify a user to pull from" if user.nil?
|
41
|
+
GitHub.invoke(:track, user) unless helper.tracking?(user)
|
42
|
+
branch ||= 'master'
|
43
|
+
|
44
|
+
puts "Switching to #{user}/#{branch}"
|
45
|
+
git "checkout #{user}/#{branch}" if git("checkout -b #{user}/#{branch}").error?
|
46
|
+
|
47
|
+
if options[:merge]
|
48
|
+
git "pull #{user} #{branch}"
|
49
|
+
git "checkout master"
|
50
|
+
git_exec "merge #{user}/#{branch}"
|
51
|
+
else
|
52
|
+
git_exec "pull #{user} #{branch}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
GitHub.describe :clone => "Clone a repo. Pass --ssh to clone from your own git@github.com schema."
|
57
|
+
GitHub.register :clone do |user, repo|
|
58
|
+
user, repo = user.split('/') unless repo
|
59
|
+
die "Specify a repo to pull from" if repo.nil?
|
60
|
+
|
61
|
+
if options[:ssh]
|
62
|
+
git_exec "clone git@github.com:#{user}/#{repo}.git"
|
63
|
+
else
|
64
|
+
git_exec "clone git://github.com/#{user}/#{repo}.git"
|
65
|
+
end
|
66
|
+
end
|
data/commands/helpers.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
GitHub.helper :user_and_repo_from do |url|
|
2
|
+
case url
|
3
|
+
when %r|^git://github\.com/([^/]+/[^/]+)$|: $1.split('/')
|
4
|
+
when %r|^(?:ssh://)?(?:git@)?github\.com:([^/]+/[^/]+)$|: $1.split('/')
|
5
|
+
else ['', '']
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
GitHub.helper :user_and_repo_for do |remote|
|
10
|
+
user_and_repo_from(url_for(remote))
|
11
|
+
end
|
12
|
+
|
13
|
+
GitHub.helper :user_for do |remote|
|
14
|
+
user_and_repo_for(remote).first
|
15
|
+
end
|
16
|
+
|
17
|
+
GitHub.helper :repo_for do |remote|
|
18
|
+
user_and_repo_for(remote).last
|
19
|
+
end
|
20
|
+
|
21
|
+
GitHub.helper :project do
|
22
|
+
repo = repo_for(:origin)
|
23
|
+
if repo == ""
|
24
|
+
if url_for(:origin) == ""
|
25
|
+
STDERR.puts "Error: missing remote 'origin'"
|
26
|
+
else
|
27
|
+
STDERR.puts "Error: remote 'origin' is not a github URL"
|
28
|
+
end
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
repo.chomp('.git')
|
32
|
+
end
|
33
|
+
|
34
|
+
GitHub.helper :url_for do |remote|
|
35
|
+
`git config --get remote.#{remote}.url`.chomp
|
36
|
+
end
|
37
|
+
|
38
|
+
GitHub.helper :remotes do
|
39
|
+
regexp = '^remote\.(.+)\.url$'
|
40
|
+
`git config --get-regexp '#{regexp}'`.split(/\n/).map do |line|
|
41
|
+
name_string, url = line.split(/ /, 2)
|
42
|
+
m, name = *name_string.match(/#{regexp}/)
|
43
|
+
[name, url]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
GitHub.helper :tracking do
|
48
|
+
remotes.map do |(name, url)|
|
49
|
+
if ur = user_and_repo_from(url)
|
50
|
+
[name, ur.first]
|
51
|
+
else
|
52
|
+
[name, url]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
GitHub.helper :tracking? do |user|
|
58
|
+
tracking.include?(user)
|
59
|
+
end
|
60
|
+
|
61
|
+
GitHub.helper :owner do
|
62
|
+
user_for(:origin)
|
63
|
+
end
|
64
|
+
|
65
|
+
GitHub.helper :user_and_branch do
|
66
|
+
raw_branch = `git rev-parse --symbolic-full-name HEAD`.chomp.sub(/^refs\/heads\//, '')
|
67
|
+
user, branch = raw_branch.split(/\//, 2)
|
68
|
+
if branch
|
69
|
+
[user, branch]
|
70
|
+
else
|
71
|
+
[owner, user]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
GitHub.helper :branch_user do
|
76
|
+
user_and_branch.first
|
77
|
+
end
|
78
|
+
|
79
|
+
GitHub.helper :branch_name do
|
80
|
+
user_and_branch.last
|
81
|
+
end
|
82
|
+
|
83
|
+
GitHub.helper :public_url_for do |user|
|
84
|
+
"git://github.com/#{user}/#{project}.git"
|
85
|
+
end
|
86
|
+
|
87
|
+
GitHub.helper :homepage_for do |user, branch|
|
88
|
+
"https://github.com/#{user}/#{project}/tree/#{branch}"
|
89
|
+
end
|
90
|
+
|
91
|
+
GitHub.helper :open do
|
92
|
+
Windoze ? 'start' : 'open'
|
93
|
+
end
|
94
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
Windoze = RUBY_PLATFORM =~ /mswin|mingw/
|
2
|
+
|
3
|
+
if Windoze
|
4
|
+
begin
|
5
|
+
require 'win32/open3'
|
6
|
+
rescue LoadError
|
7
|
+
warn "You must 'gem install win32-open3' to use the github command on Windows"
|
8
|
+
exit 1
|
9
|
+
end
|
10
|
+
else
|
11
|
+
require 'open3'
|
12
|
+
end
|
13
|
+
|
14
|
+
module GitHub
|
15
|
+
class Command
|
16
|
+
def initialize(block)
|
17
|
+
(class << self;self end).send :define_method, :command, &block
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(*args)
|
21
|
+
arity = method(:command).arity
|
22
|
+
args << nil while args.size < arity
|
23
|
+
send :command, *args
|
24
|
+
end
|
25
|
+
|
26
|
+
def helper
|
27
|
+
@helper ||= Helper.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def options
|
31
|
+
GitHub.options
|
32
|
+
end
|
33
|
+
|
34
|
+
def pgit(*command)
|
35
|
+
puts git(*command)
|
36
|
+
end
|
37
|
+
|
38
|
+
def git(*command)
|
39
|
+
sh ['git', command].flatten.join(' ')
|
40
|
+
end
|
41
|
+
|
42
|
+
def git_exec(*command)
|
43
|
+
exec ['git', command].flatten.join(' ')
|
44
|
+
end
|
45
|
+
|
46
|
+
def sh(*command)
|
47
|
+
Shell.new(*command).run
|
48
|
+
end
|
49
|
+
|
50
|
+
def die(message)
|
51
|
+
puts "=> #{message}"
|
52
|
+
exit!
|
53
|
+
end
|
54
|
+
|
55
|
+
class Shell < String
|
56
|
+
def initialize(*command)
|
57
|
+
@command = command
|
58
|
+
end
|
59
|
+
|
60
|
+
def run
|
61
|
+
GitHub.debug "sh: #{command}"
|
62
|
+
_, out, err = Open3.popen3(*@command)
|
63
|
+
|
64
|
+
out = out.read.strip
|
65
|
+
err = err.read.strip
|
66
|
+
|
67
|
+
if out.any?
|
68
|
+
replace @out = out
|
69
|
+
elsif err.any?
|
70
|
+
replace @error = err
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def command
|
75
|
+
@command.join(' ')
|
76
|
+
end
|
77
|
+
|
78
|
+
def error?
|
79
|
+
!!@error
|
80
|
+
end
|
81
|
+
|
82
|
+
def out?
|
83
|
+
!!@out
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/github.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'github/command'
|
3
|
+
require 'github/helper'
|
4
|
+
|
5
|
+
##
|
6
|
+
# Starting simple.
|
7
|
+
#
|
8
|
+
# $ github <command> <args>
|
9
|
+
#
|
10
|
+
# GitHub.register <command> do |*args|
|
11
|
+
# whatever
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# We'll probably want to use the `choice` gem for concise, tasty DSL
|
15
|
+
# arg parsing action.
|
16
|
+
#
|
17
|
+
|
18
|
+
module GitHub
|
19
|
+
extend self
|
20
|
+
|
21
|
+
BasePath = File.expand_path(File.dirname(__FILE__) + '/..')
|
22
|
+
|
23
|
+
def register(command, &block)
|
24
|
+
debug "Registered `#{command}`"
|
25
|
+
commands[command.to_s] = Command.new(block)
|
26
|
+
end
|
27
|
+
|
28
|
+
def describe(hash)
|
29
|
+
descriptions.update hash
|
30
|
+
end
|
31
|
+
|
32
|
+
def helper(command, &block)
|
33
|
+
debug "Helper'd `#{command}`"
|
34
|
+
Helper.send :define_method, command, &block
|
35
|
+
end
|
36
|
+
|
37
|
+
def activate(args)
|
38
|
+
@options = parse_options(args)
|
39
|
+
load 'helpers.rb'
|
40
|
+
load 'commands.rb'
|
41
|
+
invoke(args.shift, *args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def invoke(command, *args)
|
45
|
+
block = commands[command.to_s] || commands['default']
|
46
|
+
debug "Invoking `#{command}`"
|
47
|
+
block.call(*args)
|
48
|
+
end
|
49
|
+
|
50
|
+
def commands
|
51
|
+
@commands ||= {}
|
52
|
+
end
|
53
|
+
|
54
|
+
def descriptions
|
55
|
+
@descriptions ||= {}
|
56
|
+
end
|
57
|
+
|
58
|
+
def options
|
59
|
+
@options
|
60
|
+
end
|
61
|
+
|
62
|
+
def parse_options(args)
|
63
|
+
@debug = args.delete('--debug')
|
64
|
+
args.inject({}) do |memo, arg|
|
65
|
+
if arg =~ /^--([^=]+)=(.+)/
|
66
|
+
args.delete(arg)
|
67
|
+
memo.merge($1.to_sym => $2)
|
68
|
+
elsif arg =~ /^--(.+)/
|
69
|
+
args.delete(arg)
|
70
|
+
memo.merge($1.to_sym => true)
|
71
|
+
else
|
72
|
+
memo
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def load(file)
|
78
|
+
file[0] == ?/ ? super : super(BasePath + "/commands/#{file}")
|
79
|
+
end
|
80
|
+
|
81
|
+
def debug(*messages)
|
82
|
+
puts *messages.map { |m| "== #{m}" } if debug?
|
83
|
+
end
|
84
|
+
|
85
|
+
def debug?
|
86
|
+
!!@debug
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
GitHub.register :default do
|
91
|
+
puts "Usage: github command <space separated arguments>", ''
|
92
|
+
puts "Available commands:", ''
|
93
|
+
longest = GitHub.descriptions.map { |d,| d.to_s.size }.max
|
94
|
+
GitHub.descriptions.each do |command, desc|
|
95
|
+
command = "%-#{longest}s" % command
|
96
|
+
puts " #{command} => #{desc}"
|
97
|
+
end
|
98
|
+
puts
|
99
|
+
end
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "The owner helper" do
|
4
|
+
before(:each) do
|
5
|
+
@helper = GitHub::Helper.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return hacker" do
|
9
|
+
@helper.should_receive(:url_for).with(:origin).and_return("git://github.com/hacker/project.git")
|
10
|
+
@helper.owner.should == "hacker"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "The project helper" do
|
4
|
+
before(:each) do
|
5
|
+
@helper = GitHub::Helper.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return project-awesome" do
|
9
|
+
@helper.should_receive(:url_for).with(:origin).and_return("git://github.com/user/project-awesome.git")
|
10
|
+
@helper.project.should == "project-awesome"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should exit due to missing origin" do
|
14
|
+
@helper.should_receive(:url_for).twice.with(:origin).and_return("")
|
15
|
+
STDERR.should_receive(:puts).with("Error: missing remote 'origin'")
|
16
|
+
lambda { @helper.project }.should raise_error(SystemExit)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should exit due to non-github origin" do
|
20
|
+
@helper.should_receive(:url_for).twice.with(:origin).and_return("home:path/to/repo.git")
|
21
|
+
STDERR.should_receive(:puts).with("Error: remote 'origin' is not a github URL")
|
22
|
+
lambda { @helper.project }.should raise_error(SystemExit)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "The public_url_for helper" do
|
4
|
+
before(:each) do
|
5
|
+
@helper = GitHub::Helper.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return git://github.com/wycats/merb-core.git" do
|
9
|
+
@helper.should_receive(:url_for).with(:origin).and_return("git://github.com/user/merb-core.git")
|
10
|
+
@helper.public_url_for("wycats").should == "git://github.com/wycats/merb-core.git"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "The repo_for helper" do
|
4
|
+
before(:each) do
|
5
|
+
@helper = GitHub::Helper.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return mephisto.git" do
|
9
|
+
@helper.should_receive(:url_for).with("mojombo").and_return("git@github.com:mojombo/mephisto.git")
|
10
|
+
@helper.repo_for("mojombo").should == "mephisto.git"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "The user_and_repo_from helper" do
|
4
|
+
before(:each) do
|
5
|
+
@helper = GitHub::Helper.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should parse a git:// url" do
|
9
|
+
@helper.user_and_repo_from("git://github.com/defunkt/github.git").should == ["defunkt", "github.git"]
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should parse a ssh-based url" do
|
13
|
+
@helper.user_and_repo_from("git@github.com:mojombo/god.git").should == ["mojombo", "god.git"]
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should parse a non-standard ssh-based url" do
|
17
|
+
@helper.user_and_repo_from("ssh://git@github.com:mojombo/god.git").should == ["mojombo", "god.git"]
|
18
|
+
@helper.user_and_repo_from("github.com:mojombo/god.git").should == ["mojombo", "god.git"]
|
19
|
+
@helper.user_and_repo_from("ssh://github.com:mojombo/god.git").should == ["mojombo", "god.git"]
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return nothing for other urls" do
|
23
|
+
@helper.user_and_repo_from("home:path/to/repo.git").should == ['', '']
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return nothing for invalid git:// urls" do
|
27
|
+
@helper.user_and_repo_from("git://github.com/foo").should == ['', '']
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return nothing for invalid ssh-based urls" do
|
31
|
+
@helper.user_and_repo_from("git@github.com:kballard").should == ['', '']
|
32
|
+
@helper.user_and_repo_from("git@github.com:kballard/test/repo.git").should == ['', '']
|
33
|
+
@helper.user_and_repo_from("ssh://git@github.com:kballard").should == ['', '']
|
34
|
+
@helper.user_and_repo_from("github.com:kballard").should == ['', '']
|
35
|
+
@helper.user_and_repo_from("ssh://github.com:kballard").should == ['', '']
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "The user_for helper" do
|
4
|
+
before(:each) do
|
5
|
+
@helper = GitHub::Helper.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return defunkt" do
|
9
|
+
@helper.should_receive(:url_for).with("origin").and_return("git@github.com:defunkt/project.git")
|
10
|
+
@helper.user_for("origin").should == "defunkt"
|
11
|
+
end
|
12
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nex3-github
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Wanstrath
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-06 00:00:00 -07:00
|
13
|
+
default_executable: github
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: The official `github` command line helper for simplifying your GitHub experience.
|
17
|
+
email: chris@ozmm.org
|
18
|
+
executables:
|
19
|
+
- github
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- bin/github
|
24
|
+
- lib/github/command.rb
|
25
|
+
- lib/github/helper.rb
|
26
|
+
- lib/github.rb
|
27
|
+
- LICENSE
|
28
|
+
- README
|
29
|
+
files:
|
30
|
+
- bin/github
|
31
|
+
- commands/commands.rb
|
32
|
+
- commands/helpers.rb
|
33
|
+
- lib/github/command.rb
|
34
|
+
- lib/github/helper.rb
|
35
|
+
- lib/github.rb
|
36
|
+
- LICENSE
|
37
|
+
- README
|
38
|
+
- spec/command_spec.rb
|
39
|
+
- spec/helpers/owner_spec.rb
|
40
|
+
- spec/helpers/project_spec.rb
|
41
|
+
- spec/helpers/public_url_for_spec.rb
|
42
|
+
- spec/helpers/repo_for_spec.rb
|
43
|
+
- spec/helpers/user_and_repo_from_spec.rb
|
44
|
+
- spec/helpers/user_for_spec.rb
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
- Manifest
|
47
|
+
- github.gemspec
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://github.com/
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options:
|
52
|
+
- --line-numbers
|
53
|
+
- --inline-source
|
54
|
+
- --title
|
55
|
+
- Github
|
56
|
+
- --main
|
57
|
+
- README
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project: github
|
75
|
+
rubygems_version: 1.0.1
|
76
|
+
signing_key:
|
77
|
+
specification_version: 2
|
78
|
+
summary: The official `github` command line helper for simplifying your GitHub experience.
|
79
|
+
test_files: []
|
80
|
+
|