git_local 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26c11cea43b5910416d5670eaf5dc82f160207a6
4
- data.tar.gz: '099683934a6673775a0fe898c9424fda140a9f76'
3
+ metadata.gz: 9ef9a96b275649d0b6999c92557745d0f9379210
4
+ data.tar.gz: 4c8a19310d66ec680911d89c44817cd1bcb56cb0
5
5
  SHA512:
6
- metadata.gz: b78a382c89d92e82994fa3bbc23902003cf97949ec9da6b4c0168824e175ee764c320a89457f28c6da6463f91ef71b3c25379d0ab12927f15b2653d47f91b68a
7
- data.tar.gz: 1cc3566ee69290c2066511eae50f57c1fdf952847e00e9f39cfbb9519ec19ef66d1d13731f735afde3c5bdc24dfa2bc6bf640568a062cafb89a5d31f9e8841b5
6
+ metadata.gz: 5e364bfcd816ff9d7717bc27fa85444db4d0f8a58dd25777fcce56a801b33e89005b91b5e17d0b36537842160d3d8bed1110dd96295015c6b890ab411c8dcd9f
7
+ data.tar.gz: dbf980ee598e33d92665506531b1830598c56abfd771cae388aacade4926b86cd6f44a9ef7f6bf8abb35392544785358e7a7df29de9384ee9e7a92a28030688d
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ git_local (0.0.4)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.1)
10
+ diff-lcs (1.3)
11
+ method_source (0.8.2)
12
+ pry (0.10.4)
13
+ coderay (~> 1.1.0)
14
+ method_source (~> 0.8.1)
15
+ slop (~> 3.4)
16
+ rake (10.5.0)
17
+ rspec (3.5.0)
18
+ rspec-core (~> 3.5.0)
19
+ rspec-expectations (~> 3.5.0)
20
+ rspec-mocks (~> 3.5.0)
21
+ rspec-core (3.5.4)
22
+ rspec-support (~> 3.5.0)
23
+ rspec-expectations (3.5.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.5.0)
26
+ rspec-mocks (3.5.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.5.0)
29
+ rspec-support (3.5.0)
30
+ slop (3.6.0)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.12)
37
+ git_local!
38
+ pry (~> 0.10.4)
39
+ rake (~> 10.0)
40
+ rspec (~> 3.0)
41
+
42
+ BUNDLED WITH
43
+ 1.12.4
@@ -1,9 +1,14 @@
1
1
  module GitLocal
2
2
  class Repository
3
3
  class NotFound < StandardError
4
+
5
+ end
6
+
7
+ class InvalidArgument < StandardError
4
8
  end
5
9
 
6
10
  def initialize(org:, repo:, branch:, local_directory:)
11
+ check_for_special_characters(org, repo, branch, local_directory)
7
12
  @org = org
8
13
  @repo = repo
9
14
  @branch = branch
@@ -48,10 +53,11 @@ module GitLocal
48
53
  head = popened_io.read.chomp.split("\n").last
49
54
  Process.wait(popened_io.pid)
50
55
 
51
- popened_io = IO.popen("(cd #{path} && git remote update && git rev-parse origin/#{branch})")
56
+ popened_io = IO.popen("(cd #{path} && git remote update && git rev-parse origin/#{branch}) 2>&1")
57
+ out = popened_io.map { |line| line.chomp } || []
52
58
  remote = popened_io.read.chomp
53
59
  Process.wait(popened_io.pid)
54
- raise NotFound unless $?.to_i == 0
60
+ raise NotFound.new.exception(out.join(' ')) unless $?.to_i == 0
55
61
 
56
62
  remote != head
57
63
  end
@@ -60,6 +66,13 @@ module GitLocal
60
66
  @path ||= "#{local_directory}/#{org_repo_branch}"
61
67
  end
62
68
 
69
+ def check_for_special_characters(*args)
70
+ regexp = Regexp.new(/([A-Za-z0-9\-\_\/#]+)/)
71
+ args.each do |arg|
72
+ raise InvalidArgument if arg.gsub(regexp, '').length > 0
73
+ end
74
+ end
75
+
63
76
  private
64
77
 
65
78
  attr_reader :org, :repo, :branch, :local_directory
@@ -67,10 +80,11 @@ module GitLocal
67
80
  def clone_and_checkout
68
81
  FileUtils.makedirs(repo_path) unless Dir.exist?(repo_path)
69
82
 
70
- popened_io = IO.popen("(cd #{repo_path} && git clone git@github.com:#{org_repo}.git --branch #{branch} --single-branch #{branch} && cd #{path})")
83
+ popened_io = IO.popen("(cd #{repo_path} && git clone git@github.com:#{org_repo}.git --branch #{branch} --single-branch #{branch} && cd #{path}) 2>&1")
84
+ out = popened_io.map { |line| line.chomp } || []
71
85
  Process.wait(popened_io.pid)
72
86
 
73
- raise NotFound unless $?.to_i == 0
87
+ raise NotFound.new.exception(out.join(' ')) unless $?.to_i == 0
74
88
  end
75
89
 
76
90
  def org_repo
@@ -1,3 +1,3 @@
1
1
  module GitLocal
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Galvanize Product
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-12 00:00:00.000000000 Z
11
+ date: 2017-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,6 +76,7 @@ files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
78
  - Gemfile
79
+ - Gemfile.lock
79
80
  - LICENSE.txt
80
81
  - README.md
81
82
  - bin/setup
@@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  version: '0'
106
107
  requirements: []
107
108
  rubyforge_project:
108
- rubygems_version: 2.6.11
109
+ rubygems_version: 2.5.1
109
110
  signing_key:
110
111
  specification_version: 4
111
112
  summary: A lightweight git command line wrapper in Ruby