git-browse-remote 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/git/browse/remote/core.rb +13 -1
- data/lib/git/browse/remote/version.rb +1 -1
- data/spec/bin_spec.rb +27 -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: 84c7c1cdde0ec934fd09d23ed6e43b47bc6fae85
|
4
|
+
data.tar.gz: ae732ca4fe86a98a4f0d4cf77cf0f5709ad4ca1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5311b353f6adb40226f98d684d4695df80060323bd52ae6056bca62ba388b2d1978f9bd5be03177b3f55ce02b1ecc0e440a9d75ab8238d435aef3e05f1ae62eb
|
7
|
+
data.tar.gz: 2c79fbd27cee8ec1f78b5b585dc203c17821ab774413f841704d038b7429e3ff46e81e1ab0f1293fddc1c294635235fb5823f8fc17335c250a3eebc562196027
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'git/browse/remote/git'
|
2
2
|
require 'pathname'
|
3
|
+
require 'uri'
|
3
4
|
|
4
5
|
module Git::Browse::Remote
|
5
6
|
class Path < Array
|
@@ -77,7 +78,18 @@ module Git::Browse::Remote
|
|
77
78
|
remote_url = `git config remote.#{remote}.url`[/.+/] or
|
78
79
|
abort "Could not get remote url: #{remote}"
|
79
80
|
|
80
|
-
|
81
|
+
unless %r(^\w+://) === remote_url
|
82
|
+
# SCP-like URLs of form "[user@]host.xz:path/to/repo.git"
|
83
|
+
# will be converted to "ssh://[user@]host.xz/path/to/repo.git"
|
84
|
+
remote_url = 'ssh://' + remote_url.sub(/:/, '/')
|
85
|
+
end
|
86
|
+
|
87
|
+
# Normal URLs
|
88
|
+
u = URI(remote_url)
|
89
|
+
host = u.host
|
90
|
+
port = u.port
|
91
|
+
host_port = if port == u.default_port then host else "#{host}:#{port}" end
|
92
|
+
path = u.path.sub(%r(^/), '').split('/')
|
81
93
|
path.last.sub!(/\.git$/, '')
|
82
94
|
path = Path.new(path)
|
83
95
|
|
data/spec/bin_spec.rb
CHANGED
@@ -53,6 +53,15 @@ RSpec.configure do |config|
|
|
53
53
|
git :remote, 'add', 'origin', 'https://github.com/user/repo.git'
|
54
54
|
git :remote, 'add', 'origin2', 'git@gh-mirror.host:user/repo2'
|
55
55
|
|
56
|
+
git :remote, 'add', 'origin3', 'ssh://git@my-git-host.com:9999/user/repo2'
|
57
|
+
git :config, '--local', 'browse-remote.my-git-host.com.top', 'https://{host}/{path}'
|
58
|
+
|
59
|
+
git :remote, 'add', 'origin4', 'ssh://git@my-git-host2.com:9999/user/repo2'
|
60
|
+
git :config, '--local', 'browse-remote.my-git-host2.com.top', 'https://{host_port}/{path}'
|
61
|
+
|
62
|
+
git :remote, 'add', 'origin5', 'git@my-git-host3.com:9999/user/repo2' # here 9999 is a part of path
|
63
|
+
git :config, '--local', 'browse-remote.my-git-host3.com.top', 'https://{host_port}/{path}'
|
64
|
+
|
56
65
|
FileUtils.copy_file ROOT + 'README.md', 'README.md'
|
57
66
|
git :add, 'README.md'
|
58
67
|
git :commit, '-m' '1st commit'
|
@@ -245,6 +254,24 @@ describe 'git-browse-remote' do
|
|
245
254
|
expect(opened_url).to eq("https://gh-mirror.host/user/repo2")
|
246
255
|
end
|
247
256
|
end
|
257
|
+
|
258
|
+
when_run_with_args '--remote', 'origin3' do
|
259
|
+
it 'should open the specified remote page, `host` does not include port' do
|
260
|
+
expect(opened_url).to eq("https://my-git-host.com/user/repo2")
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
when_run_with_args '--remote', 'origin4' do
|
265
|
+
it 'should open the specified remote page, using `host_port` variable' do
|
266
|
+
expect(opened_url).to eq("https://my-git-host2.com:9999/user/repo2")
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
when_run_with_args '--remote', 'origin5' do
|
271
|
+
it 'should open the specified remote page on a SCP-like URL' do
|
272
|
+
expect(opened_url).to eq("https://my-git-host3.com/9999/user/repo2")
|
273
|
+
end
|
274
|
+
end
|
248
275
|
end
|
249
276
|
|
250
277
|
context 'on some branch' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-browse-remote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- motemen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|