git_go 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_go (0.1.1)
4
+ git_go (0.1.2)
5
5
  net-ssh (~> 2.6.2)
6
6
  thor (~> 0.16.0)
7
7
 
@@ -3,6 +3,6 @@
3
3
  module GitGo
4
4
 
5
5
  # @return [String] the current GitGo version.
6
- VERSION = "0.1.1"
6
+ VERSION = "0.1.2"
7
7
  end
8
8
 
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
- @user = ENV["GIT_GO_USER"]
29
- @host = ENV["GIT_GO_HOST"]
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
- if [user, host].include?(nil)
32
- puts "GIT_GO_USER and GIT_GO_HOST not set."
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
- exit(1)
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["GIT_GO_USER"] = "git"
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
 
@@ -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["GIT_GO_USER"] = nil
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["GIT_GO_USER"] = "git"
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["GIT_GO_USER"] = "git"
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["GIT_GO_USER"] = "git"
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
@@ -13,8 +13,7 @@ RSpec.configure do |config|
13
13
  config.filter_run :focus
14
14
 
15
15
  config.before do
16
- ENV["GIT_GO_USER"] = "git"
17
- ENV["GIT_GO_HOST"] = "127.0.0.1" # localhost
16
+ ENV["GIT_GO_URI"] = "git@127.0.0.1" # localhost
18
17
  end
19
18
  end
20
19
 
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.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: -3457378250373614310
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: -3457378250373614310
107
+ hash: -3903107512716536942
108
108
  requirements: []
109
109
  rubyforge_project:
110
110
  rubygems_version: 1.8.23