git-browse-remote 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 +4 -4
- data/git-browse-remote.gemspec +1 -1
- data/lib/git/browse/remote/core.rb +12 -1
- data/lib/git/browse/remote/git.rb +4 -0
- data/lib/git/browse/remote/version.rb +1 -1
- data/spec/bin_spec.rb +27 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03838bd1fa4034f16f770aabd9e668a43ff66591
|
4
|
+
data.tar.gz: 3926c8b5d0aef8d0c051f8307f3e89da25f97d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 403e7f3f6b99a8b856b6d6601e5508dd8ae6d8b0dfca86a3d9f9783ac6186601d4840b2c1df5fe360b1737960ce1b8b9e8ac738602a7631bffd789743ecb40ad
|
7
|
+
data.tar.gz: c75a96cef9c44e2ff24d21deefdc540034a9a24c1f05fd611e8073418988642c1c81651051f8d2213c06000a41552dd5327d77d1e90b0160094c5bb6839d0a75
|
data/git-browse-remote.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "rake"
|
22
22
|
spec.add_development_dependency 'rspec', '~> 2'
|
23
23
|
spec.add_development_dependency 'simplecov', '0.7.1'
|
24
|
-
spec.add_development_dependency 'guard'
|
24
|
+
spec.add_development_dependency 'guard', '~> 1'
|
25
25
|
spec.add_development_dependency 'guard-rspec'
|
26
26
|
spec.add_development_dependency 'terminal-notifier-guard'
|
27
27
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'git/browse/remote/git'
|
2
|
+
require 'pathname'
|
2
3
|
|
3
4
|
module Git::Browse::Remote
|
4
5
|
class Path < Array
|
@@ -7,6 +8,12 @@ module Git::Browse::Remote
|
|
7
8
|
end
|
8
9
|
end
|
9
10
|
|
11
|
+
class Filepath < Pathname
|
12
|
+
def to_s
|
13
|
+
Pathname.new(Git.show_prefix).join(super).cleanpath.to_s
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
10
17
|
class Core
|
11
18
|
attr_accessor :line, :file
|
12
19
|
|
@@ -15,7 +22,7 @@ module Git::Browse::Remote
|
|
15
22
|
:top => 'https://{host}/{path}',
|
16
23
|
:ref => 'https://{host}/{path}/tree/{short_ref}',
|
17
24
|
:rev => 'https://{host}/{path}/commit/{commit}',
|
18
|
-
:file => 'https://{host}/{path}/blob/{short_rev}/{file}{line && "#L%d" % line}'
|
25
|
+
:file => 'https://{host}/{path}/{file.directory? and :tree or :blob}/{short_rev}/{file}{line && "#L%d" % line}',
|
19
26
|
},
|
20
27
|
|
21
28
|
:gitweb => {
|
@@ -47,6 +54,10 @@ module Git::Browse::Remote
|
|
47
54
|
self.target, @file = nil, target
|
48
55
|
end
|
49
56
|
|
57
|
+
if @file && File.exists?(@file)
|
58
|
+
@file = Filepath.new(@file)
|
59
|
+
end
|
60
|
+
|
50
61
|
if target
|
51
62
|
if Git.is_valid_rev? target
|
52
63
|
@ref = Git.full_name_of_rev(target)
|
data/spec/bin_spec.rb
CHANGED
@@ -57,7 +57,10 @@ RSpec.configure do |config|
|
|
57
57
|
git :add, 'README.md'
|
58
58
|
git :commit, '-m' '1st commit'
|
59
59
|
|
60
|
-
|
60
|
+
FileUtils.mkdir_p 'foo/bar'
|
61
|
+
FileUtils.touch 'foo/bar/baz.txt'
|
62
|
+
git :add, 'foo/bar/baz.txt'
|
63
|
+
git :commit, '-m' '2nd commit'
|
61
64
|
|
62
65
|
git :checkout, '-b', 'branch-1'
|
63
66
|
|
@@ -327,6 +330,29 @@ describe 'git-browse-remote' do
|
|
327
330
|
end
|
328
331
|
end
|
329
332
|
|
333
|
+
when_run_with_args 'foo/bar' do
|
334
|
+
it 'should accept directory as an argument' do
|
335
|
+
expect(opened_url).to eq("https://github.com/user/repo/tree/master/foo/bar")
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
context 'when at non-toplevel directory' do
|
340
|
+
before { @_pwd = Dir.pwd; Dir.chdir 'foo' }
|
341
|
+
after { Dir.chdir @_pwd }
|
342
|
+
|
343
|
+
when_run_with_args '../README.md' do
|
344
|
+
it 'should resolve relative path' do
|
345
|
+
expect(opened_url).to eq("https://github.com/user/repo/blob/master/README.md")
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
when_run_with_args '.' do
|
350
|
+
it 'should resolve relative path' do
|
351
|
+
expect(opened_url).to eq("https://github.com/user/repo/tree/master/foo")
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
330
356
|
it 'should abort on invalid ref' do
|
331
357
|
expect { git_browse_remote([ 'xxx-nonexistent-ref' ]) }.to raise_error SystemExit
|
332
358
|
end
|
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.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- motemen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: guard
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: guard-rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|