lock_diff 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: 49e90bd5a6ed3fbc00553bdcda81175a6284e823
4
- data.tar.gz: 55e43f00d8cbb5debda5a9a0f5a8e36bda970443
3
+ metadata.gz: 8c0b8383d775ad39dbd93fff93530652b7e60e3d
4
+ data.tar.gz: 34ef1bd10ad27bb846e4ba47c7926dd9a0281ae4
5
5
  SHA512:
6
- metadata.gz: f4b8f38e2309147797b3b5204deaa874a82f638d670254cd82a6171e9186b8104f60264ec81f43c1374c5ded1cb4c083156a4a49732a4eac24db0df427943dad
7
- data.tar.gz: 18447bbe8452d330ba39ee8af80dcd43d40f8932696e36e200d72c915660c8db5db4e49f2c7e9eac67b3ba81b3f18264c1bda0ee2a128faa86e25a224631da8c
6
+ metadata.gz: f2885f2572e82adffed6fa073a2f1fa7b7ae0500a0f8aca59039fe4a52b2da2163f764c0357978016c133e1592a60fedf2da8273b4e8c66a36e39808d086eff4
7
+ data.tar.gz: c076daeb953b7da33bb7a20fc2e2e607791261b15cedc41b862493f8fb9b4043e30b4b33647c940ad01b33d10a055913cb2c8bca36dccde52421a2ea9f1b3e50
data/README.md CHANGED
@@ -2,7 +2,12 @@
2
2
 
3
3
  [![CircleCI](https://circleci.com/gh/vividmuimui/lock_diff.svg?style=svg)](https://circleci.com/gh/vividmuimui/lock_diff)
4
4
 
5
- This Gem is generates `changelog url`, `github compare link` by lock file of Github pull request. And comment to pull request.
5
+ This gem detects changes to your package manager (e.g. Gemfile) and generates a Markdown-formatted diff including:
6
+
7
+ * links to the corresponding package's change logs
8
+ * Github `...`-delineated diff links for the relevant changes
9
+
10
+ It also optionally posts the diff as a comment to the pull request responsible for the package update.
6
11
 
7
12
  Like this.
8
13
 
@@ -31,7 +36,7 @@ Or install it yourself as:
31
36
 
32
37
  ## Usage
33
38
 
34
- Require `GITHUB_ACCESS_TOKEN` environment.
39
+ lock_diff requires you to provide a `GITHUB_ACCESS_TOKEN` as an environment variable.
35
40
 
36
41
  ### Command line
37
42
 
@@ -40,9 +45,11 @@ $ lock_diff
40
45
  Usage: lock_diff [options]
41
46
  -r, --repository=REPOSITORY required. Like as "user/repository"
42
47
  -n, --number=PULL_REQUEST_NUMBER required
43
- --post-comment=true or false dafault=false
48
+ --post-comment=true or false (default=false. Print result to stdout when false.)
44
49
  ```
45
50
 
51
+ For example, to comment on https://github.com/vividmuimui/rails_tutorial/pull/26#issuecomment-312491272, run this command:
52
+
46
53
  ```sh
47
54
  $ lock_diff -r "vividmuimui/rails_tutorial" -n 26 --post-comment=false
48
55
  ```
@@ -54,6 +61,31 @@ require 'lock_diff'
54
61
  LockDiff.run(repository: "vividmuimui/rails_tutorial", number: 26, post_comment: false)
55
62
  ```
56
63
 
64
+ ### For Tachikoma pull request
65
+
66
+ When used in conjunction with [tachikoma](https://rubygems.org/gems/tachikoma), use the `lock_diff_for_tachikoma` command instead of `lock_diff`.
67
+ `lock_diff_for_tachikoma` automatically detects and comments on the most recent tachikoma pull request.
68
+
69
+ #### Command line
70
+
71
+ ```sh
72
+ $ lock_diff
73
+ Usage: lock_diff_for_tachikoma [options]
74
+ -r, --repository=REPOSITORY required. Like as "user/repository"
75
+ --post-comment=true or false default=false
76
+ ```
77
+
78
+ ```sh
79
+ $ lock_diff_for_tachikoma -r "vividmuimui/rails_tutorial" --post-comment=false
80
+ ```
81
+
82
+ #### Ruby
83
+
84
+ ```ruby
85
+ require 'lock_diff'
86
+ LockDiff.lock_diff_for_tachikoma(repository: "vividmuimui/rails_tutorial", post_comment: false)
87
+ ```
88
+
57
89
  ## Development
58
90
 
59
91
  TODO:
data/exe/lock_diff CHANGED
@@ -10,7 +10,7 @@ opt = OptionParser.new
10
10
 
11
11
  opt.on('-r', '--repository=REPOSITORY', 'required. Like as "user/repository"') { |v| options[:repository] = v }
12
12
  opt.on('-n', '--number=PULL_REQUEST_NUMBER', 'required') { |v| options[:number] = v }
13
- opt.on('--post-comment=true or false', 'dafault=false') { |v| options[:post_comment] = v }
13
+ opt.on('--post-comment=true or false', '(default=false. Print result to stdout when false.)') { |v| options[:post_comment] = v }
14
14
  opt.parse!
15
15
 
16
16
  unless options[:repository] && options[:number]
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "lock_diff"
4
+ require "optparse"
5
+
6
+ options = {
7
+ post_comment: false
8
+ }
9
+ opt = OptionParser.new
10
+
11
+ opt.on('-r', '--repository=REPOSITORY', 'required. Like as "user/repository"') { |v| options[:repository] = v }
12
+ opt.on('--post-comment=true or false', '(default=false. Print result to stdout when false.)') { |v| options[:post_comment] = v }
13
+ opt.parse!
14
+
15
+ unless options[:repository]
16
+ $stdout.puts opt.help
17
+ else
18
+ LockDiff.run_by_latest_tachikoma(options)
19
+ end
@@ -24,6 +24,11 @@ module LockDiff
24
24
  Github::PullRequest.new(@client.pull_request(repository, number))
25
25
  end
26
26
 
27
+ def latest_pull_request(repository, limit: 3)
28
+ @client.pull_requests(repository).first(limit).
29
+ map { |pull_request| Github::PullRequest.new(pull_request) }
30
+ end
31
+
27
32
  def pull_request_content_path(repository, number, file_name)
28
33
  content = @client.pull_request_files(repository, number).
29
34
  find { |file| file.filename.include?(file_name) }
@@ -13,6 +13,18 @@ module LockDiff
13
13
  def head_sha
14
14
  @pr.head.sha
15
15
  end
16
+
17
+ def base_ref
18
+ @pr.base.ref
19
+ end
20
+
21
+ def head_ref
22
+ @pr.head.ref
23
+ end
24
+
25
+ def number
26
+ @pr.number
27
+ end
16
28
  end
17
29
  end
18
30
  end
@@ -1,3 +1,3 @@
1
1
  module LockDiff
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/lock_diff.rb CHANGED
@@ -26,10 +26,20 @@ module LockDiff
26
26
  $stdout.puts result
27
27
  end
28
28
  end
29
+
30
+ def run_by_latest_tachikoma(repository:, post_comment: false)
31
+ pr = Github.client.latest_pull_request(repository, limit: 10).
32
+ find { |pull_request| pull_request.head_ref.include?("tachikoma") }
33
+ if pr
34
+ run(repository: repository, number: pr.number, post_comment: post_comment)
35
+ else
36
+ LockDiff.logger.info("Not found pull request by tachikoma.")
37
+ end
38
+ end
29
39
  end
30
40
 
31
41
  self.client_class = Github
32
42
  self.formatter = Formatter::GithubMarkdown
33
43
  self.strategy = Gem
34
- self.logger = Logger.new(nil)
44
+ self.logger = Logger.new($stdout)
35
45
  end
data/lock_diff.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["vividmuimui"]
10
10
  spec.email = ["vivid.muimui@gmail.com"]
11
11
 
12
- spec.summary = %q{Generate links by Gemfile.lock of Github PR, and post comment to it.}
13
- spec.description = %q{Generate links by Gemfile.lock of Github PR, and post comment to it.}
12
+ spec.summary = %q{This gem detects changes to your package manager (e.g. Gemfile) and generates a Markdown-formatted diff.}
13
+ spec.description = %q{This gem detects changes to your package manager (e.g. Gemfile) and generates a Markdown-formatted diff.}
14
14
  # spec.homepage = "https://github.com/vividmuimui/lock_diff"
15
15
  spec.homepage = ""
16
16
  spec.license = "MIT"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lock_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - vividmuimui
@@ -108,11 +108,13 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description: Generate links by Gemfile.lock of Github PR, and post comment to it.
111
+ description: This gem detects changes to your package manager (e.g. Gemfile) and generates
112
+ a Markdown-formatted diff.
112
113
  email:
113
114
  - vivid.muimui@gmail.com
114
115
  executables:
115
116
  - lock_diff
117
+ - lock_diff_for_tachikoma
116
118
  extensions: []
117
119
  extra_rdoc_files: []
118
120
  files:
@@ -127,6 +129,7 @@ files:
127
129
  - bin/console
128
130
  - bin/setup
129
131
  - exe/lock_diff
132
+ - exe/lock_diff_for_tachikoma
130
133
  - lib/lock_diff.rb
131
134
  - lib/lock_diff/formatter/github_markdown.rb
132
135
  - lib/lock_diff/gem.rb
@@ -171,5 +174,6 @@ rubyforge_project:
171
174
  rubygems_version: 2.6.11
172
175
  signing_key:
173
176
  specification_version: 4
174
- summary: Generate links by Gemfile.lock of Github PR, and post comment to it.
177
+ summary: This gem detects changes to your package manager (e.g. Gemfile) and generates
178
+ a Markdown-formatted diff.
175
179
  test_files: []