percy-client 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/percy/client/environment.rb +13 -2
- data/lib/percy/client/version.rb +1 -1
- data/spec/lib/percy/client/environment_spec.rb +31 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f6af0faf6189f292d1d1a286825a429857143c2
|
4
|
+
data.tar.gz: fedbcc8381eabc6eef7f871c3b6c99a60df1366b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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('[:/]([^/]+\/[^/]
|
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
|
data/lib/percy/client/version.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2015-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|