git-browse-remote 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -43
- data/lib/git/browse/remote/core.rb +6 -2
- data/lib/git/browse/remote/runner.rb +6 -2
- data/lib/git/browse/remote/version.rb +1 -1
- data/spec/lib/git/browse/remote/runner_spec.rb +40 -0
- metadata +21 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7604534269d3542a8be61db5f95efcbd175a3347
|
4
|
+
data.tar.gz: 9ea9f7eff7777cade451b9443cc0b23b91b72943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b28ee1b89f121eb58715e0d91fae7655d8a758099c9ac951ca70663d6fcaa2b82019f66ee3f201e209345a32a58a0c05ac305ec737c223d6844672157ad0c5cd
|
7
|
+
data.tar.gz: 9226f355535e88501718eedcb46dd588c1c22f1ef22ea7b39f8e472d17f7c27b90a607bc41934ba98d3633f7c29820ce799029a5d8402782aba27da120cf3959
|
data/README.md
CHANGED
@@ -1,13 +1,20 @@
|
|
1
|
-
git-browse-remote [![Build Status](https://travis-ci.org/motemen/git-browse-remote.png?branch=master)](https://travis-ci.org/motemen/git-browse-remote)
|
1
|
+
git-browse-remote [![Build Status](https://travis-ci.org/motemen/git-browse-remote.png?branch=master)](https://travis-ci.org/motemen/git-browse-remote) [![Gem Version](https://badge.fury.io/rb/git-browse-remote.png)](http://badge.fury.io/rb/git-browse-remote)
|
2
2
|
=================
|
3
3
|
|
4
4
|
`git-browse-remote` helps viewing remote repositories e.g. GitHub in your browser.
|
5
5
|
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
```
|
10
|
+
[sudo] gem install git-browse-remote
|
11
|
+
```
|
12
|
+
|
6
13
|
Usage
|
7
14
|
-----
|
8
15
|
|
9
16
|
```
|
10
|
-
git browse-remote [-r|--remote <remote>] [--top|--rev|--ref] [-L <n> [<commit> | <remote>] [<file>]
|
17
|
+
git browse-remote [-r|--remote <remote>] [--top|--rev|--ref] [-L <n>] [<commit> | <remote>] [<file> | <directory>]
|
11
18
|
```
|
12
19
|
|
13
20
|
`git-browse-remote` opens your web browser by `git web--browse` to show current repository in browser.
|
@@ -23,47 +30,7 @@ git browse-remote [-r|--remote <remote>] [--top|--rev|--ref] [-L <n> [<commit> |
|
|
23
30
|
|
24
31
|
As a special case, if <var>commit</var> is invalid and an valid remote name, that remore repository's page is opened.
|
25
32
|
|
26
|
-
|
27
|
-
-------------
|
28
|
-
|
29
|
-
`git browse-remote` stores url mapping in ~/.gitconfig.
|
30
|
-
To initialize this, execute with `--init` option.
|
31
|
-
|
32
|
-
```
|
33
|
-
% git browse-remote --init
|
34
|
-
Writing config for github.com...
|
35
|
-
Mappings generated:
|
36
|
-
browse-remote.github.com.top https://{host}/{path}
|
37
|
-
browse-remote.github.com.ref https://{host}/{path}/tree/{short_ref}
|
38
|
-
browse-remote.github.com.rev https://{host}/{path}/commit/{commit}
|
39
|
-
browse-remote.github.com.file https://{host}/{path}/blob/{short_rev}/{file}{line && "#L%d" % line}
|
40
|
-
```
|
41
|
-
|
42
|
-
Execute `git config browse-remote.<host>.{top|ref|rev} <url template>`
|
43
|
-
to register other hosts mappings.
|
44
|
-
|
45
|
-
Especially, if you have a GitHub Enterprise repository, run
|
46
|
-
|
47
|
-
```
|
48
|
-
% git browse-remote --init <ghe host>=github
|
49
|
-
```
|
50
|
-
|
51
|
-
to easyly setup url mappings. `--init <host>=gitweb` is also available.
|
52
|
-
|
53
|
-
Variables available in url template
|
54
|
-
-----------------------------------
|
55
|
-
|
56
|
-
* `host` (eg. "github.com")
|
57
|
-
* `path` (eg. "motemen/git-browse-remote")
|
58
|
-
* Sliceable, subscribable like an `Array`
|
59
|
-
* `ref` (eg. "refs/heads/master")
|
60
|
-
* `short_ref` (eg. "master")
|
61
|
-
* `commit` (eg. "04f7c64ba9d524cf311a673ddce5722b2441e2ea")
|
62
|
-
* `short_commit` (eg. "04f7c64b")
|
63
|
-
* `rev` (ref or commit)
|
64
|
-
* `short_rev` (short_ref or short_commit)
|
65
|
-
* `file` (eg. "bin/git-browse-remote")
|
66
|
-
* `line` (eg. 30)
|
33
|
+
For more information such as custom URL mappings, please visit the [web page](http://motemen.github.io/git-browse-remote/).
|
67
34
|
|
68
35
|
## Contributing
|
69
36
|
|
@@ -15,14 +15,14 @@ module Git::Browse::Remote
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class Core
|
18
|
-
attr_accessor :
|
18
|
+
attr_accessor :lines, :file
|
19
19
|
|
20
20
|
MAPPING_RECIPES = {
|
21
21
|
:github => {
|
22
22
|
:top => 'https://{host}/{path}',
|
23
23
|
:ref => 'https://{host}/{path}/tree/{short_ref}',
|
24
24
|
:rev => 'https://{host}/{path}/commit/{commit}',
|
25
|
-
:file => 'https://{host}/{path}/{file.directory? and :tree or :blob}/{short_rev}/{file}{
|
25
|
+
:file => 'https://{host}/{path}/{file.directory? and :tree or :blob}/{short_rev}/{file}{lines && "#L%s" % lines.join("-")}',
|
26
26
|
},
|
27
27
|
|
28
28
|
:gitweb => {
|
@@ -175,6 +175,10 @@ module Git::Browse::Remote
|
|
175
175
|
_ref(true)
|
176
176
|
end
|
177
177
|
|
178
|
+
def line
|
179
|
+
lines and lines.first
|
180
|
+
end
|
181
|
+
|
178
182
|
def target=(target)
|
179
183
|
@target = target
|
180
184
|
end
|
@@ -9,7 +9,7 @@ module Git::Browse::Remote
|
|
9
9
|
@core = Core.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def parse_args!
|
13
13
|
OptionParser.new do |opt|
|
14
14
|
opt.banner = 'git browse-remote [options] [<commit> | <remote>] [--] [<file>]'
|
15
15
|
opt.version = VERSION
|
@@ -34,10 +34,14 @@ module Git::Browse::Remote
|
|
34
34
|
STDERR.puts 'Mappings generated:'
|
35
35
|
exec "git config --get-regexp ^browse-remote\\.#{host}\\."
|
36
36
|
end
|
37
|
-
opt.on('-L <n>', 'specify line number (only meaningful on file mode)'
|
37
|
+
opt.on('-L <n>[,<m>]', 'specify line number (only meaningful on file mode)') { |lines| @core.lines = lines.split(/[,\-]/).map(&:to_i).uniq }
|
38
38
|
end.parse!(@args)
|
39
39
|
|
40
40
|
@core.target, @core.file = *@args[0..1]
|
41
|
+
end
|
42
|
+
|
43
|
+
def run
|
44
|
+
parse_args!
|
41
45
|
|
42
46
|
if @stdout
|
43
47
|
puts @core.url
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'git/browse/remote/runner'
|
2
|
+
|
3
|
+
def when_args_parsed(args, &block)
|
4
|
+
context "with args #{args}" do
|
5
|
+
subject(:runner) { Git::Browse::Remote::Runner.new(args) }
|
6
|
+
before { runner.parse_args! }
|
7
|
+
|
8
|
+
instance_eval(&block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def core
|
13
|
+
runner.instance_variable_get(:@core)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe Git::Browse::Remote::Runner do
|
17
|
+
when_args_parsed ['--top'] do
|
18
|
+
it 'should set @core.mode to :top' do
|
19
|
+
expect(core.mode).to eq(:top)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
when_args_parsed ['--remote', 'upstream'] do
|
24
|
+
it 'should set @core.remote to "upstream"' do
|
25
|
+
expect(core.remote).to eq('upstream')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
when_args_parsed ['-L337'] do
|
30
|
+
it 'should set @core.line to 337' do
|
31
|
+
expect(core.line).to eq(337)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
when_args_parsed ['-L337,400'] do
|
36
|
+
it 'should set @core.lines to [337,400]' do
|
37
|
+
expect(core.lines).to eq([337,400])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
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.1.0
|
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: 2014-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -70,42 +70,42 @@ dependencies:
|
|
70
70
|
name: guard
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
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
82
|
version: '1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: guard-rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: terminal-notifier-guard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description:
|
@@ -116,8 +116,8 @@ executables:
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
-
- .gitignore
|
120
|
-
- .travis.yml
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
121
121
|
- Gemfile
|
122
122
|
- Guardfile
|
123
123
|
- LICENSE.txt
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/git/browse/remote/version.rb
|
133
133
|
- spec/bin_spec.rb
|
134
134
|
- spec/lib/git/browse/remote/core_spec.rb
|
135
|
+
- spec/lib/git/browse/remote/runner_spec.rb
|
135
136
|
homepage: https://github.com/motemen/git-browse-remote
|
136
137
|
licenses:
|
137
138
|
- MIT
|
@@ -142,21 +143,21 @@ require_paths:
|
|
142
143
|
- lib
|
143
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
144
145
|
requirements:
|
145
|
-
- -
|
146
|
+
- - ">="
|
146
147
|
- !ruby/object:Gem::Version
|
147
148
|
version: '0'
|
148
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
150
|
requirements:
|
150
|
-
- -
|
151
|
+
- - ">="
|
151
152
|
- !ruby/object:Gem::Version
|
152
153
|
version: '0'
|
153
154
|
requirements: []
|
154
155
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.2.2
|
156
157
|
signing_key:
|
157
158
|
specification_version: 4
|
158
159
|
summary: Open web browser to view remote Git repositories
|
159
160
|
test_files:
|
160
161
|
- spec/bin_spec.rb
|
161
162
|
- spec/lib/git/browse/remote/core_spec.rb
|
162
|
-
|
163
|
+
- spec/lib/git/browse/remote/runner_spec.rb
|