git_go 0.1.1 → 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/Gemfile.lock +1 -1
- data/lib/git_go/version.rb +1 -1
- data/lib/git_go.rb +29 -5
- data/spec/lib/git_go/connection/remote_spec.rb +1 -2
- data/spec/lib/git_go_spec.rb +14 -10
- data/spec/spec_helper.rb +1 -2
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/git_go/version.rb
CHANGED
data/lib/git_go.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
+
require "uri"
|
4
|
+
|
3
5
|
require "rubygems"
|
4
6
|
require "thor"
|
5
7
|
require "net/ssh"
|
@@ -25,14 +27,36 @@ module GitGo
|
|
25
27
|
#
|
26
28
|
# @return [GitGo::Core] an instance of GitGo::Core
|
27
29
|
def initialize
|
28
|
-
|
29
|
-
|
30
|
+
if ENV["GIT_GO_URI"].nil?
|
31
|
+
puts
|
32
|
+
puts "GIT_GO_URI not set."
|
33
|
+
puts "Run `gg instructions` for more details."
|
34
|
+
puts
|
35
|
+
puts "NOTE"
|
36
|
+
puts
|
37
|
+
puts "GIT_GO_USER and GIT_GO_HOST have been removed."
|
38
|
+
puts "Please use GIT_GO_URI instead. For example:"
|
39
|
+
puts
|
40
|
+
puts " export GIT_GO_URI=git@repositories.example.com"
|
41
|
+
puts
|
42
|
+
puts "Or with a static IP:"
|
43
|
+
puts
|
44
|
+
puts " export GIT_GO_URI=git@207.97.227.239"
|
45
|
+
puts
|
46
|
+
return exit(1)
|
47
|
+
end
|
30
48
|
|
31
|
-
|
32
|
-
|
49
|
+
begin
|
50
|
+
uri = URI.parse("ssh://#{ENV["GIT_GO_URI"]}")
|
51
|
+
rescue URI::InvalidURIError
|
52
|
+
puts
|
53
|
+
puts "Your GIT_GO_URI (#{ENV["GIT_GO_URI"]}) is invalid."
|
33
54
|
puts "Run `gg instructions` for more details."
|
34
|
-
|
55
|
+
puts
|
56
|
+
return exit(1)
|
35
57
|
end
|
58
|
+
|
59
|
+
@user, @host = uri.user, uri.host
|
36
60
|
end
|
37
61
|
|
38
62
|
# Creates and returns a new instance of GitGo::Connection.
|
@@ -9,8 +9,7 @@ describe GitGo::Connection::Remote do
|
|
9
9
|
let(:ssh) { mock("Net::SSH") }
|
10
10
|
|
11
11
|
before do
|
12
|
-
ENV["
|
13
|
-
ENV["GIT_GO_HOST"] = "192.168.1.1" # Remote IP
|
12
|
+
ENV["GIT_GO_URI"] = "git@192.168.1.1" # remote ip
|
14
13
|
Net::SSH.stubs(:start).returns(ssh)
|
15
14
|
end
|
16
15
|
|
data/spec/lib/git_go_spec.rb
CHANGED
@@ -2,27 +2,32 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe GitGo do
|
5
|
+
describe GitGo::Core do
|
6
6
|
it "should exit when initializing without the environment variables" do
|
7
|
-
ENV["
|
8
|
-
ENV["GIT_GO_HOST"] = nil
|
7
|
+
ENV["GIT_GO_URI"] = nil
|
9
8
|
|
9
|
+
GitGo::Core.any_instance.stubs(:puts).times(15)
|
10
|
+
GitGo::Core.any_instance.expects(:exit).with(1)
|
11
|
+
GitGo::Core.new
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should exit on invalid URIs" do
|
15
|
+
ENV["GIT_GO_URI"] = ""
|
16
|
+
|
17
|
+
GitGo::Core.any_instance.stubs(:puts).times(4)
|
10
18
|
GitGo::Core.any_instance.expects(:exit).with(1)
|
11
|
-
GitGo::Core.any_instance.stubs(:puts)
|
12
19
|
GitGo::Core.new
|
13
20
|
end
|
14
21
|
|
15
22
|
it "should not exit when initializing with the environment variables" do
|
16
|
-
ENV["
|
17
|
-
ENV["GIT_GO_HOST"] = "127.0.0.1"
|
23
|
+
ENV["GIT_GO_URI"] = "git@127.0.0.1"
|
18
24
|
|
19
25
|
GitGo::Core.any_instance.expects(:exit).never
|
20
26
|
GitGo::Core.new
|
21
27
|
end
|
22
28
|
|
23
29
|
it "should initialize a GitGo::Connection::Remote connection" do
|
24
|
-
ENV["
|
25
|
-
ENV["GIT_GO_HOST"] = "192.168.1.1"
|
30
|
+
ENV["GIT_GO_URI"] = "git@192.168.1.1"
|
26
31
|
|
27
32
|
core = GitGo::Core.new
|
28
33
|
GitGo::Connection::Remote.expects(:new).with(core)
|
@@ -31,8 +36,7 @@ describe GitGo do
|
|
31
36
|
end
|
32
37
|
|
33
38
|
it "should initialize a GitGo::Connection::Local connection" do
|
34
|
-
ENV["
|
35
|
-
ENV["GIT_GO_HOST"] = "127.0.0.1"
|
39
|
+
ENV["GIT_GO_URI"] = "git@127.0.0.1"
|
36
40
|
|
37
41
|
core = GitGo::Core.new
|
38
42
|
GitGo::Connection::Local.expects(:new).with(core)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_go
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -95,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
segments:
|
97
97
|
- 0
|
98
|
-
hash: -
|
98
|
+
hash: -3903107512716536942
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
none: false
|
101
101
|
requirements:
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
segments:
|
106
106
|
- 0
|
107
|
-
hash: -
|
107
|
+
hash: -3903107512716536942
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
110
|
rubygems_version: 1.8.23
|