gh_compare 0.1.3 → 0.1.4
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -11
- data/bin/gh_compare +19 -4
- data/lib/gh_compare/version.rb +1 -1
- data/lib/gh_compare.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86877317391ee3415a229a9375e59a9e123a071920856f3ea5154d28fa3c86ba
|
4
|
+
data.tar.gz: 75f5e9d408a90459b5a67f03e436112d5871c60faef29dca712016786252c196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz: '
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0493f939e0ce4ed7083e35238932d483eeb04c152c9c96b2c6c59a2ccbb2816d200c7496328ab58d22b40fa06f83d203d411f0530a39839b35193485723365bf'
|
7
|
+
data.tar.gz: ca56c90e1bd6523674b4a8e268478670258521ada18164a8e00437347b77878e85d80ebf8b67a061dcf75043b5a98c7987544d2f9a8997976fda9ae4e9e3c2a7
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,22 +6,18 @@ Generate GitHub compare url like [this](https://github.com/kenzo-tanaka/gh_compa
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
```
|
10
|
-
gem
|
9
|
+
```shell
|
10
|
+
gem install gh_compare
|
11
11
|
```
|
12
12
|
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install gh_compare
|
20
|
-
|
21
13
|
## Usage
|
22
14
|
|
23
15
|
```shell
|
24
|
-
gh_compare
|
16
|
+
gh_compare -n [number]
|
17
|
+
```
|
18
|
+
|
19
|
+
```shell
|
20
|
+
gh_compare -d [from-hash] [to-hash]
|
25
21
|
```
|
26
22
|
|
27
23
|
## Development
|
data/bin/gh_compare
CHANGED
@@ -1,7 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
raise ArgumentError, "wrong number of arguments (given #{ARGV.length}, expected 2)" if ARGV.length != 2
|
4
|
-
|
5
3
|
require_relative '../lib/gh_compare'
|
6
|
-
|
7
|
-
|
4
|
+
require 'optparse'
|
5
|
+
options = {}
|
6
|
+
|
7
|
+
OptionParser.new do |opt|
|
8
|
+
opt.on('--n=NUM', Integer) { |v| options[:num] = v }
|
9
|
+
opt.on('--d==V,V', Array) { |v| options[:commits] = v }
|
10
|
+
|
11
|
+
opt.parse!(ARGV)
|
12
|
+
end
|
13
|
+
|
14
|
+
if options[:num]
|
15
|
+
compare = GhCompare::CommitCompare.new
|
16
|
+
puts compare.compare_before(options[:num])
|
17
|
+
end
|
18
|
+
|
19
|
+
if options[:commits]
|
20
|
+
compare = GhCompare::CommitCompare.new
|
21
|
+
puts compare.compare_url(options[:commits][0], options[:commits][1])
|
22
|
+
end
|
data/lib/gh_compare/version.rb
CHANGED
data/lib/gh_compare.rb
CHANGED
@@ -18,6 +18,10 @@ module GhCompare
|
|
18
18
|
remote_url + "/compare/#{from}...#{to}"
|
19
19
|
end
|
20
20
|
|
21
|
+
def compare_before(num)
|
22
|
+
compare_url(head_before(num), head)
|
23
|
+
end
|
24
|
+
|
21
25
|
private
|
22
26
|
|
23
27
|
def get_remote_origin
|
@@ -31,5 +35,13 @@ module GhCompare
|
|
31
35
|
def ssh_to_url
|
32
36
|
"https://github.com/#{remote_origin.gsub(/git@github.com:/, '').gsub(/\.git$/, '')}"
|
33
37
|
end
|
38
|
+
|
39
|
+
def head
|
40
|
+
`git rev-parse HEAD`.strip
|
41
|
+
end
|
42
|
+
|
43
|
+
def head_before(num)
|
44
|
+
`git rev-parse HEAD~#{num}`.strip
|
45
|
+
end
|
34
46
|
end
|
35
47
|
end
|