gh_compare 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7fa476cdcd112fb8b30f4b301bc3d36d81d8485c5a0fefa0d590cc68db63e86
4
- data.tar.gz: 64f0e3cc9621189a660b750e59dd630861590d7cd7c8251069c1685f052073bc
3
+ metadata.gz: 86877317391ee3415a229a9375e59a9e123a071920856f3ea5154d28fa3c86ba
4
+ data.tar.gz: 75f5e9d408a90459b5a67f03e436112d5871c60faef29dca712016786252c196
5
5
  SHA512:
6
- metadata.gz: '09370c36ddee2280ab84303a4fb780b3bd54ed98db9912a29d183ba094d141704d7630981c28b7b4bb82008e17049f3198c3de147283b7a5b2b6051e6fef5410'
7
- data.tar.gz: 37eaa579978a91caf22424fc33327b8d5a2e41c1ce80e9664444f440a76fdeb725d59f0c96959e8b2d20ca891bbfd512d9a953b7861e52889478bcffebc18fc1
6
+ metadata.gz: '0493f939e0ce4ed7083e35238932d483eeb04c152c9c96b2c6c59a2ccbb2816d200c7496328ab58d22b40fa06f83d203d411f0530a39839b35193485723365bf'
7
+ data.tar.gz: ca56c90e1bd6523674b4a8e268478670258521ada18164a8e00437347b77878e85d80ebf8b67a061dcf75043b5a98c7987544d2f9a8997976fda9ae4e9e3c2a7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gh_compare (0.1.2)
4
+ gh_compare (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- ```ruby
10
- gem 'gh_compare'
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 [from-hash] [to-hash]
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
- compare = GhCompare::CommitCompare.new
7
- puts compare.compare_url(ARGV[0], ARGV[1])
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
@@ -1,3 +1,3 @@
1
1
  module GhCompare
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh_compare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kenzo-tanaka