whatsup_github 0.1.1 → 0.2.0

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: da5ac25ee48ecbeb1219dae8e22c966ea1d3954b04c6cec344b1698095020671
4
- data.tar.gz: f11b3a4b544675cc37cde564950b30b9162f3933335d44ae6e831408b8ed53db
3
+ metadata.gz: 3c5a5193535cbcad7a2e79333943ca9761e7b6bc06a867fffacaf3abac90ce47
4
+ data.tar.gz: e0f92a5c0619da8911035a61b3cb0e17dab44344b99db02986da0fbb67cf4c76
5
5
  SHA512:
6
- metadata.gz: f159bfdf36cd305cdbf2bfb7c16ce0aeae27e8405a87c0cc999fb0866f7a395d7de68e20e622a8b2dd69483a54bf2d7f7ab415b2523fa3b6af9241d179fe005a
7
- data.tar.gz: 19275e16e836a8ef676cf03a8e0a98fd41b60699772c7d3890efd15f01cf67a08bdc54ebc808ef45af46d5875c2a47b912db4dc317b9d726565152b2a64db36d
6
+ metadata.gz: 43c4beaa0b90f93aeb01ab7a2f2643702ac8d078bd3b21801a250a7918dba077ecee5f9138d731e3817ad78719769bc4167f32ce7bdfad480c374e790a498251
7
+ data.tar.gz: 9247198a00d96c500236f093dc7b458e256220b8763ab6831207c014f1da6acd5d24aa95f3fc47b45cf5850e727543e8d53515a0684432b07f0d58d96fb9dff5
@@ -1 +1 @@
1
- ruby-2.6.5
1
+ ruby-2.7.1
@@ -1,3 +1,7 @@
1
+ ## 0.2.0
2
+
3
+ - Implemented two types of labels in configuration: 'optional' and 'required'.
4
+
1
5
  ## 0.0.1
2
6
 
3
7
  The tool is released as a gem.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- whatsup_github (0.1.1)
4
+ whatsup_github (0.2.0)
5
5
  netrc (~> 0.10)
6
6
  octokit (~> 4.14)
7
7
  thor (~> 0.20)
@@ -40,7 +40,7 @@ GEM
40
40
  cucumber-tag_expressions (1.1.1)
41
41
  cucumber-wire (0.0.1)
42
42
  diff-lcs (1.3)
43
- faraday (1.0.0)
43
+ faraday (1.0.1)
44
44
  multipart-post (>= 1.2, < 3)
45
45
  ffi (1.12.2)
46
46
  gherkin (5.1.0)
@@ -55,7 +55,7 @@ GEM
55
55
  pry (0.13.0)
56
56
  coderay (~> 1.1)
57
57
  method_source (~> 1.0)
58
- public_suffix (4.0.3)
58
+ public_suffix (4.0.5)
59
59
  rake (13.0.1)
60
60
  rspec (3.9.0)
61
61
  rspec-core (~> 3.9.0)
@@ -77,6 +77,7 @@ GEM
77
77
 
78
78
  PLATFORMS
79
79
  ruby
80
+ x86_64-darwin-19
80
81
 
81
82
  DEPENDENCIES
82
83
  aruba (~> 0.14)
data/README.md CHANGED
@@ -1,27 +1,29 @@
1
- # WhatsupGithub
1
+ # whatsup_github
2
2
 
3
3
  [![Build status](https://travis-ci.com/dshevtsov/whatsup_github.svg?branch=master)](https://travis-ci.com/dshevtsov/whatsup_github)
4
4
  [![Gem version](https://img.shields.io/gem/v/whatsup_github.svg?style=flat)](https://rubygems.org/gems/whatsup_github)
5
5
 
6
- This tool helps to update data for [Whats New on DevDocs](http://devdocs.magento.com/whats-new.html).
6
+ This tool helps updating data for [Whats New on DevDocs](http://devdocs.magento.com/whats-new.html).
7
7
  It filters GitHub pull requests and generates a data file.
8
- One pull request - one data entity.
8
+ One pull request sources one data entity.
9
9
  All filtering parameters are set in a configuration file, except dates.
10
10
  _Since_ date is set as a CLI argument and the _till_ date is always the moment when the command is run.
11
11
 
12
- ## Prerequisite
12
+ ## What's generated
13
13
 
14
- The resulting data file is generated from data pulled from GitHub.
14
+ A resulting YAML file `tmp/whats-new.yml` is generated from GitHub data.
15
15
 
16
16
  ### `description`
17
17
 
18
- Pull requests that will appear in search must have text that will fill out the _Description_ cell.
19
- The text must follow the `whatsnew` keyword and be located at the very bottom of a pull request description field.
18
+ Text for `description` is taken from individual pull request's description (same as body).
19
+ The text must follow the `whatsnew` keyword and be located at the end.
20
+
21
+ Example:
20
22
 
21
23
  ```
22
24
  This pull request adds ...
23
25
 
24
- ...
26
+ Some other details about this pull request.
25
27
 
26
28
  whatsnew
27
29
  Added documentation about [New Magento feature](https://devdocs.magento.com/new-magento-feature.html).
@@ -29,22 +31,34 @@ Added documentation about [New Magento feature](https://devdocs.magento.com/new-
29
31
 
30
32
  ### `type`
31
33
 
32
- Set as a list of `labels` in `.whatsup.yml`.
34
+ Set as a list of `labels` in `.whatsup.yml`. There are two types of labels in configuration:
35
+ - `required` are labels that must include `whatsnew`. Otherwise, resulting output will warn about missing `whatsnew`.
36
+ - `optional` are labels that may include `whatsnew`. If `whatsnew` is missing, you won't get any notification about this.
33
37
 
34
38
  ### `versions`
35
39
 
36
- Any GitHub label that starts from a digit followed by a dot (see regex `\d\.`).
40
+ Any GitHub label that starts from a digit followed by a period like in regex `\d\.`.
37
41
  Examples: `2.3.x`, `1.0.3-msi`, `2.x`
38
42
 
39
43
  ### `date`
40
44
 
41
- The date when pull request was merged.
45
+ Date when the pull request was merged.
46
+
47
+ ### `link`
48
+
49
+ URL of the pull request.
42
50
 
43
51
  ## Installation
44
52
 
45
- Same as any other gem.
53
+ This gem can be installed as a system command-line tool or as a command-line tool available in a project.
54
+
55
+ ### System installation
56
+
57
+ ```
58
+ gem install whatsup_github
59
+ ```
46
60
 
47
- ### Using Bundler as a part of your project
61
+ ### Project installation
48
62
 
49
63
  Add to your Gemfile:
50
64
 
@@ -52,18 +66,12 @@ Add to your Gemfile:
52
66
  gem 'whatsup_github'
53
67
  ```
54
68
 
55
- And then execute:
69
+ And install:
56
70
 
57
71
  ```bash
58
72
  bundle
59
73
  ```
60
74
 
61
- ### Separately
62
-
63
- ```
64
- gem install whatsup_github
65
- ```
66
-
67
75
  ## Configuration
68
76
 
69
77
  The configuration file [`.whatsup.yml`](lib/template/.whatsup.yml) will be created automatically after first run unless it's already there.
@@ -72,6 +80,20 @@ The configuration file [`.whatsup.yml`](lib/template/.whatsup.yml) will be creat
72
80
 
73
81
  Use [`~/.netrc`](https://github.com/octokit/octokit.rb#using-a-netrc-file) file for authentication.
74
82
 
83
+ ```
84
+ machine api.github.com
85
+ login <GitHub login>
86
+ password <GitHub token>
87
+ ```
88
+
89
+ Example:
90
+
91
+ ```
92
+ machine api.github.com
93
+ login dshevtsov
94
+ password y9o6YvEoa7IukRWUFdnkpuxNjJ3uwiDQp4zkAdU0
95
+ ```
96
+
75
97
  ## Usage
76
98
 
77
99
  ```bash
@@ -116,7 +138,7 @@ rake spec
116
138
 
117
139
  #### features
118
140
 
119
- To run cucumber tests:
141
+ To run Cucumber tests:
120
142
 
121
143
  ```
122
144
  rake features
@@ -126,9 +148,29 @@ To pass the `output_file.feature` tests, you need to generate a non-empty `whats
126
148
  To test just file:
127
149
 
128
150
  ```
129
- bundle exec cucumber features/output_file.feature
151
+ bundle exec cucumber features/since.feature
130
152
  ```
131
153
 
154
+ NOTE: Cucumber tests will use the configuration file from code `lib/template/.whatsup.yml`.
155
+
156
+ #### Individual files
157
+
158
+ Individual files can have tests at the end of a file in a format like:
159
+
160
+ ```ruby
161
+ if $PROGRAM_NAME == __FILE__
162
+ # test code here
163
+ end
164
+ ```
165
+
166
+ To run such test, run the corresponding file:
167
+
168
+ ```bash
169
+ ruby lib/whatsup_github/config-reader.rb
170
+ ```
171
+
172
+ The tests use the root `.whatsup.yml` file to read configuration.
173
+
132
174
  ## Contributing
133
175
 
134
176
  Bug reports and pull requests are welcome on GitHub at https://github.com/dshevtsov/whatsup_github. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -6,9 +6,11 @@ repos:
6
6
 
7
7
  # Labels also will be used as a 'type' value in the output file
8
8
  labels:
9
- - New Topic
10
- - Major Update
11
- - Technical
9
+ required:
10
+ - New Topic
11
+ - Major Update
12
+ optional:
13
+ - Technical
12
14
 
13
15
  # Format of output file
14
16
  output_format:
@@ -12,18 +12,52 @@ module WhatsupGithub
12
12
  @config = {}
13
13
  end
14
14
 
15
- def read(*options)
15
+ def read
16
16
  unless File.exist?(@file)
17
17
  dist_file = File.expand_path("../template/#{@file}", __dir__)
18
18
  FileUtils.cp dist_file, @file
19
19
  end
20
- load_from_yaml.dig options.join ','
21
- end
22
-
23
- def load_from_yaml
24
20
  @config = YAML.load_file @file
25
21
  return {} if !@config
26
22
  @config
27
23
  end
24
+
25
+ def repos
26
+ read.dig 'repos'
27
+ end
28
+
29
+ def base_branch
30
+ read.dig 'base_branch'
31
+ end
32
+
33
+ def output_format
34
+ read.dig 'output_format'
35
+ end
36
+
37
+ def labels
38
+ required_labels + optional_labels
39
+ end
40
+
41
+ def required_labels
42
+ res = read.dig 'labels', 'required'
43
+ return [] unless res
44
+ res
45
+ end
46
+
47
+ def optional_labels
48
+ res = read.dig 'labels', 'optional'
49
+ return [] unless res
50
+ res
51
+ end
28
52
  end
29
53
  end
54
+
55
+ if $PROGRAM_NAME == __FILE__
56
+ config = WhatsupGithub::Config.instance
57
+ p config.repos
58
+ p config.base_branch
59
+ p config.output_format
60
+ p config.labels
61
+ p config.required_labels
62
+ p config.optional_labels
63
+ end
@@ -22,7 +22,7 @@ module WhatsupGithub
22
22
  private
23
23
 
24
24
  # def access_token
25
- # credentials.read 'github_token'
25
+ # credentials.dig 'github_token'
26
26
  # end
27
27
 
28
28
  def configuration
@@ -30,11 +30,11 @@ module WhatsupGithub
30
30
  end
31
31
 
32
32
  def labels
33
- configuration.read 'labels'
33
+ configuration.labels
34
34
  end
35
35
 
36
36
  def base_branch
37
- configuration.read 'base_branch'
37
+ configuration.base_branch
38
38
  end
39
39
 
40
40
  def client
@@ -51,3 +51,10 @@ module WhatsupGithub
51
51
  end
52
52
  end
53
53
  end
54
+
55
+ if $PROGRAM_NAME == __FILE__
56
+ require 'date'
57
+ two_weeks_ago = (Date.today - 14).to_s
58
+ pulls = WhatsupGithub::Pulls.new(repo: 'magento/devdocs', since: two_weeks_ago)
59
+ p pulls.filtered
60
+ end
@@ -15,7 +15,11 @@ module WhatsupGithub
15
15
  end
16
16
 
17
17
  def labels_from_config
18
- @config.read('labels')
18
+ @config.labels
19
+ end
20
+
21
+ def required_labels
22
+ @config.required_labels
19
23
  end
20
24
 
21
25
  def versions
@@ -41,9 +45,11 @@ module WhatsupGithub
41
45
  end
42
46
 
43
47
  def description
48
+ # If a PR body includes a phrase 'whatsnew', then parse the body.
49
+ # If there are at least one required label but PR body does not include what's new, warn about missing 'whatsnew'
44
50
  if body.include?('whatsnew')
45
51
  parse_body
46
- else
52
+ elsif !(labels & required_labels).empty? && !body.include?('whatsnew')
47
53
  message = "MISSING whatsnew in the #{type} PR \##{pr_number}: \"#{title}\" assigned to #{assignee} (#{link})"
48
54
  puts message
49
55
  message
@@ -8,7 +8,7 @@ module WhatsupGithub
8
8
  attr_reader :repos, :since
9
9
 
10
10
  def initialize(args = {})
11
- @repos = config.read('repos')
11
+ @repos = config.repos
12
12
  @since = args[:since]
13
13
  end
14
14
 
@@ -14,7 +14,7 @@ module WhatsupGithub
14
14
  end
15
15
 
16
16
  def run
17
- format = @config.read 'output_format'
17
+ format = @config.output_format
18
18
  raise 'Cannot find "output_format" in config.yml' unless format
19
19
  table if format.include? 'markdown'
20
20
  data if format.include? 'yaml'
@@ -1,3 +1,3 @@
1
1
  module WhatsupGithub
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -33,6 +33,8 @@ Gem::Specification.new do |spec|
33
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
34
  spec.require_paths = ["lib"]
35
35
 
36
+ spec.required_ruby_version = '>= 2.4.0'
37
+
36
38
  spec.add_dependency "octokit", "~> 4.14"
37
39
  spec.add_dependency "thor", "~> 0.20"
38
40
  spec.add_dependency "netrc", "~> 0.10"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whatsup_github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dima Shevtsov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-26 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.12'
139
- description:
139
+ description:
140
140
  email:
141
141
  - shevtsov@adobe.com
142
142
  executables:
@@ -177,7 +177,7 @@ metadata:
177
177
  homepage_uri: https://github.com/dshevtsov/whatsup_github
178
178
  source_code_uri: https://github.com/dshevtsov/whatsup_github
179
179
  changelog_uri: https://github.com/dshevtsov/whatsup_github/blob/master/CHANGELOG.md
180
- post_install_message:
180
+ post_install_message:
181
181
  rdoc_options: []
182
182
  require_paths:
183
183
  - lib
@@ -185,15 +185,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
185
  requirements:
186
186
  - - ">="
187
187
  - !ruby/object:Gem::Version
188
- version: '0'
188
+ version: 2.4.0
189
189
  required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  requirements:
191
191
  - - ">="
192
192
  - !ruby/object:Gem::Version
193
193
  version: '0'
194
194
  requirements: []
195
- rubygems_version: 3.1.2
196
- signing_key:
195
+ rubygems_version: 3.1.4
196
+ signing_key:
197
197
  specification_version: 4
198
198
  summary: Collect info from GitHub pull requests.
199
199
  test_files: []