gh_compare 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e910e7601be562e029ae4831b27e61f9ca99fe610eb3f49eaa23e6c4a8760ff3
4
- data.tar.gz: 0d1e10898e1abb6f3716ae7f72d9a0ba4aa33f22d9a7908452a6f025945ecca2
3
+ metadata.gz: 86877317391ee3415a229a9375e59a9e123a071920856f3ea5154d28fa3c86ba
4
+ data.tar.gz: 75f5e9d408a90459b5a67f03e436112d5871c60faef29dca712016786252c196
5
5
  SHA512:
6
- metadata.gz: 31073c7644971d43d7ff589a17d9ea7080e169c7b73c2ab2cdda4b8ca689e96b92d6cabe5d7def1f57d13c6e557895119f1f4dfcfed5080e764c65578c369fd1
7
- data.tar.gz: 24204b6e4e6286412015140276b7bd7281036ff50796c10dbaefd29a5df9d4aa0cfcc804c7b82eb17df2eb3b678b4be01e9cd9cc833a675089225ca1721ec80f
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.0)
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
data/gh_compare.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
32
  end
33
33
  spec.bindir = 'bin'
34
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
35
35
  spec.require_paths = ['lib']
36
36
 
37
37
  spec.add_development_dependency 'bundler', '~> 1.17'
@@ -1,3 +1,3 @@
1
1
  module GhCompare
2
- VERSION = "0.1.0"
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.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kenzo-tanaka
@@ -55,7 +55,8 @@ dependencies:
55
55
  description: Generate GitHub compare url
56
56
  email:
57
57
  - kenzou.kenzou104809@gmail.com
58
- executables: []
58
+ executables:
59
+ - gh_compare
59
60
  extensions: []
60
61
  extra_rdoc_files: []
61
62
  files:
@@ -68,9 +69,7 @@ files:
68
69
  - LICENSE.txt
69
70
  - README.md
70
71
  - Rakefile
71
- - bin/console
72
72
  - bin/gh_compare
73
- - bin/setup
74
73
  - gh_compare.gemspec
75
74
  - lib/gh_compare.rb
76
75
  - lib/gh_compare/version.rb
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "gh_compare"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here