percy-client 0.2.5 → 0.2.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7bdc0235c385840d4ec620b1acc715cf4d5ff5d
4
- data.tar.gz: 348d42bf9fdb3eab082dcbe7792a5ceb908c1fb1
3
+ metadata.gz: 8f6af0faf6189f292d1d1a286825a429857143c2
4
+ data.tar.gz: fedbcc8381eabc6eef7f871c3b6c99a60df1366b
5
5
  SHA512:
6
- metadata.gz: ee7213d7dc36a823973ddb6aafa6d6f2245da9cfe522f913ef48a50b09d4c60f6cd61d72d1056003703afe5ea00e0034545f13b7b1cff49a5a421a75df16653c
7
- data.tar.gz: d3b374b37dc133b1167b9d02c8d8bbdf16e07ab64c7f1519b653a86ae923d5b6ec5766c858f695f5dc1fb33380df76888d138e2d48aae4bc5e4103cdb0eb6532
6
+ metadata.gz: 44a0e1b2611e2167d5e5d5246d96ba56cc3e33a2736c9ad5fe0fe2e5d403f618601bfdfc1ff95c79829c23bc6aee4fea36778f9df815d56da331c5d05be035f8
7
+ data.tar.gz: 42252d79be679cfdcb585c40eb683b207e7b0ee79370ee4c45441b9965d5caa0f04d599633f6994538b2d5b7bd17d947b4f1a89e90db5ffc7051a856e87a2461
@@ -87,11 +87,16 @@ module Percy
87
87
  when :circle
88
88
  "#{ENV['CIRCLE_PROJECT_USERNAME']}/#{ENV['CIRCLE_PROJECT_REPONAME']}"
89
89
  else
90
- origin_url = `git config --get remote.origin.url`
90
+ origin_url = _get_origin_url.strip
91
91
  if origin_url == ''
92
92
  raise Percy::Client::Environment::RepoNotFoundError.new('No local git repository found.')
93
93
  end
94
- match = origin_url.match(Regexp.new('[:/]([^/]+\/[^/]+)\.git'))
94
+ match = origin_url.match(Regexp.new('[:/]([^/]+\/[^/]+?)(\.git)?\Z'))
95
+ if !match
96
+ raise Percy::Client::Environment::RepoNotFoundError.new(
97
+ "Could not determine repository name from URL: #{origin_url.inspect}\n" +
98
+ "You can manually set PERCY_REPO to fix this.")
99
+ end
95
100
  match[1]
96
101
  end
97
102
  end
@@ -113,6 +118,12 @@ module Percy
113
118
  # Unfortunately, codeship always returns 'false' for CI_PULL_REQUEST. For now, return nil.
114
119
  end
115
120
  end
121
+
122
+ # @private
123
+ def self._get_origin_url
124
+ `git config --get remote.origin.url`
125
+ end
126
+ class << self; private :_get_origin_url; end
116
127
  end
117
128
  end
118
129
  end
@@ -1,5 +1,5 @@
1
1
  module Percy
2
2
  class Client
3
- VERSION = '0.2.5'
3
+ VERSION = '0.2.6'
4
4
  end
5
5
  end
@@ -96,6 +96,37 @@ RSpec.describe Percy::Client::Environment do
96
96
  ENV['PERCY_REPO_SLUG'] = 'percy/slug'
97
97
  expect(Percy::Client::Environment.repo).to eq('percy/slug')
98
98
  end
99
+ it 'handles git ssh urls' do
100
+ expect(Percy::Client::Environment).to receive(:_get_origin_url)
101
+ .once.and_return('git@github.com:org-name/repo-name.git')
102
+ expect(Percy::Client::Environment.repo).to eq('org-name/repo-name')
103
+
104
+ expect(Percy::Client::Environment).to receive(:_get_origin_url)
105
+ .once.and_return('git@github.com:org-name/repo-name.org.git')
106
+ expect(Percy::Client::Environment.repo).to eq('org-name/repo-name.org')
107
+
108
+ expect(Percy::Client::Environment).to receive(:_get_origin_url)
109
+ .once.and_return('git@custom-local-hostname:org-name/repo-name.org')
110
+ expect(Percy::Client::Environment.repo).to eq('org-name/repo-name.org')
111
+ end
112
+ it 'handles git https urls' do
113
+ expect(Percy::Client::Environment).to receive(:_get_origin_url)
114
+ .once.and_return('https://github.com/org-name/repo-name.git')
115
+ expect(Percy::Client::Environment.repo).to eq('org-name/repo-name')
116
+
117
+ expect(Percy::Client::Environment).to receive(:_get_origin_url)
118
+ .once.and_return('https://github.com/org-name/repo-name.org.git')
119
+ expect(Percy::Client::Environment.repo).to eq('org-name/repo-name.org')
120
+
121
+ expect(Percy::Client::Environment).to receive(:_get_origin_url)
122
+ .once.and_return("https://github.com/org-name/repo-name.org\n")
123
+ expect(Percy::Client::Environment.repo).to eq('org-name/repo-name.org')
124
+ end
125
+ it 'errors if unable to parse local repo name' do
126
+ expect(Percy::Client::Environment).to receive(:_get_origin_url).once.and_return('foo')
127
+ expect { Percy::Client::Environment.repo }.to raise_error(
128
+ Percy::Client::Environment::RepoNotFoundError)
129
+ end
99
130
  end
100
131
  end
101
132
  context 'in Jenkins CI' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percy-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Perceptual Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday