whatsup_github 0.5.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/linter.yml +3 -2
- data/Gemfile.lock +6 -5
- data/README.md +39 -5
- data/lib/template/.whatsup.yml +4 -0
- data/lib/whatsup_github/cli.rb +4 -0
- data/lib/whatsup_github/config_reader.rb +11 -1
- data/lib/whatsup_github/enterprise_client.rb +43 -0
- data/lib/whatsup_github/pulls.rb +29 -13
- data/lib/whatsup_github/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b0f2b56ca6f8f7f4ff62318ad9c8dd44c7add49172901ab659740ad028dc10d
|
4
|
+
data.tar.gz: 561373dde9c7dbdc2e790ad1b5103eb4a3d0ded7e9f9fee9d1368cc7f01c05d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4eec00e901377b84c16a9441c1c2c36c0bf0b977195405ed0889d6b1dccd3cb6a427e4dd3c9cd73a82b8c0e5f20599697f68aa9a77eb4a162248635936e5a771
|
7
|
+
data.tar.gz: bc64795d79bbabb3fbe6d304ac5b67cd40a40ab1780f3752c9ed5788d6968805fb8c961666a709fe7e9cf323d2cca514fc4c0810a7dc428a60a172f68731f987
|
@@ -42,7 +42,8 @@ jobs:
|
|
42
42
|
# Run Linter against code base #
|
43
43
|
################################
|
44
44
|
- name: Lint Code Base
|
45
|
-
uses: github/super-linter@v4
|
45
|
+
uses: github/super-linter/slim@v4
|
46
46
|
env:
|
47
|
-
VALIDATE_ALL_CODEBASE: false
|
48
47
|
DEFAULT_BRANCH: main
|
48
|
+
VALIDATE_ALL_CODEBASE: false
|
49
|
+
VALIDATE_GITLEAKS: false
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
whatsup_github (0.
|
4
|
+
whatsup_github (1.0.1)
|
5
5
|
netrc (~> 0.11)
|
6
6
|
octokit (~> 6.0)
|
7
7
|
thor (~> 1.2)
|
@@ -47,7 +47,7 @@ GEM
|
|
47
47
|
cucumber-messages (18.0.0)
|
48
48
|
cucumber-tag-expressions (4.1.0)
|
49
49
|
diff-lcs (1.5.0)
|
50
|
-
faraday (2.7.
|
50
|
+
faraday (2.7.3)
|
51
51
|
faraday-net_http (>= 2.0, < 3.1)
|
52
52
|
ruby2_keywords (>= 0.0.4)
|
53
53
|
faraday-net_http (3.0.2)
|
@@ -64,7 +64,7 @@ GEM
|
|
64
64
|
octokit (6.0.1)
|
65
65
|
faraday (>= 1, < 3)
|
66
66
|
sawyer (~> 0.9)
|
67
|
-
pry (0.14.
|
67
|
+
pry (0.14.2)
|
68
68
|
coderay (~> 1.1)
|
69
69
|
method_source (~> 1.0)
|
70
70
|
public_suffix (5.0.1)
|
@@ -75,10 +75,10 @@ GEM
|
|
75
75
|
rspec-mocks (~> 3.12.0)
|
76
76
|
rspec-core (3.12.0)
|
77
77
|
rspec-support (~> 3.12.0)
|
78
|
-
rspec-expectations (3.12.
|
78
|
+
rspec-expectations (3.12.2)
|
79
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
80
80
|
rspec-support (~> 3.12.0)
|
81
|
-
rspec-mocks (3.12.
|
81
|
+
rspec-mocks (3.12.3)
|
82
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
83
83
|
rspec-support (~> 3.12.0)
|
84
84
|
rspec-support (3.12.0)
|
@@ -91,6 +91,7 @@ GEM
|
|
91
91
|
thor (1.2.1)
|
92
92
|
|
93
93
|
PLATFORMS
|
94
|
+
arm64-darwin-22
|
94
95
|
ruby
|
95
96
|
|
96
97
|
DEPENDENCIES
|
data/README.md
CHANGED
@@ -9,6 +9,22 @@ 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
|
+
## CLI
|
13
|
+
|
14
|
+
```console
|
15
|
+
Commands:
|
16
|
+
whatsup_github help [COMMAND] # Describe available commands or one specific command
|
17
|
+
whatsup_github since DATE # Filters pull requests since the specified date till now. Default: last 7 days.
|
18
|
+
whatsup_github version # Current version of the gem
|
19
|
+
|
20
|
+
Usage:
|
21
|
+
whatsup_github since DATE
|
22
|
+
|
23
|
+
Options:
|
24
|
+
[--config=CONFIG] # Relative path to the configuration file.
|
25
|
+
# Default: .whatsup.yml
|
26
|
+
```
|
27
|
+
|
12
28
|
## What's generated
|
13
29
|
|
14
30
|
A resulting YAML file `tmp/whats-new.yml` is generated from GitHub data.
|
@@ -38,7 +54,7 @@ Set as a list of `labels` in `.whatsup.yml`. There are two types of labels in co
|
|
38
54
|
|
39
55
|
### `versions`
|
40
56
|
|
41
|
-
Any GitHub label that starts from a digit followed by a period like in
|
57
|
+
Any GitHub label that starts from a digit followed by a period like in regular expression `\d\.`.
|
42
58
|
Examples: `2.3.x`, `1.0.3-msi`, `2.x`
|
43
59
|
|
44
60
|
### `date`
|
@@ -59,7 +75,7 @@ Merge commit SHA of the pull request.
|
|
59
75
|
|
60
76
|
### `membership`
|
61
77
|
|
62
|
-
|
78
|
+
Membership of the contributor in a configured organization.
|
63
79
|
|
64
80
|
### `labels`
|
65
81
|
|
@@ -91,7 +107,13 @@ bundle
|
|
91
107
|
|
92
108
|
## Configuration
|
93
109
|
|
94
|
-
The configuration file [`.whatsup.yml`](lib/template/.whatsup.yml) will be created automatically after first run unless it's already there.
|
110
|
+
The default configuration file [`.whatsup.yml`](lib/template/.whatsup.yml) will be created automatically after first run unless it's already there.
|
111
|
+
|
112
|
+
To use non-default location or name of the file, use the --config option. Example:
|
113
|
+
|
114
|
+
```shell
|
115
|
+
whatsup_github since 'apr 9' --config 'configs/whatsup_bp.yml'
|
116
|
+
```
|
95
117
|
|
96
118
|
## Authentication
|
97
119
|
|
@@ -109,8 +131,20 @@ Example:
|
|
109
131
|
|
110
132
|
```config
|
111
133
|
machine api.github.com
|
112
|
-
login
|
134
|
+
login mypubliclogin
|
135
|
+
password y9o6YvEoa7IukRWUFdnkpuxNjJ3uwiDQp4zkAdU0
|
136
|
+
```
|
137
|
+
|
138
|
+
Example with GitHub Enterprise:
|
139
|
+
|
140
|
+
```config
|
141
|
+
machine api.github.com
|
142
|
+
login mypubliclogin
|
113
143
|
password y9o6YvEoa7IukRWUFdnkpuxNjJ3uwiDQp4zkAdU0
|
144
|
+
|
145
|
+
machine git.enterprise.example.com
|
146
|
+
login myenterpriselogin
|
147
|
+
password GtH7yhvEoa7Iuksdo&TFuxNjJ3uwiDQhjbiu8&yhJhG
|
114
148
|
```
|
115
149
|
|
116
150
|
### With an environment variable
|
@@ -202,7 +236,7 @@ The tests use the root `.whatsup.yml` file to read configuration.
|
|
202
236
|
|
203
237
|
## Contributing
|
204
238
|
|
205
|
-
Bug reports and pull requests are welcome
|
239
|
+
Bug reports and pull requests are welcome. 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.
|
206
240
|
|
207
241
|
## License
|
208
242
|
|
data/lib/template/.whatsup.yml
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# Parameters for a GitHub search query
|
2
2
|
base_branch: master
|
3
3
|
|
4
|
+
# Set hostname to read repos at GitHub Enterprise
|
5
|
+
# enterprise: <hostname>
|
6
|
+
|
4
7
|
# The list of repositories to scan for pull requests
|
8
|
+
# For repos at GitHub Enterprise, add a prefix 'enterprise:'. Example: enterprise:magento/devdocs.
|
5
9
|
repos:
|
6
10
|
- magento/devdocs
|
7
11
|
|
data/lib/whatsup_github/cli.rb
CHANGED
@@ -7,7 +7,11 @@ module WhatsupGithub
|
|
7
7
|
# CLI options
|
8
8
|
class CLI < Thor
|
9
9
|
desc 'since DATE', 'Filters pull requests since the specified date till now. Default: last 7 days.'
|
10
|
+
option :config,
|
11
|
+
desc: 'Relative path to the configuration file.',
|
12
|
+
default: '.whatsup.yml'
|
10
13
|
def since(date = Date.today - 7)
|
14
|
+
WhatsupGithub::Config.filename = options[:config]
|
11
15
|
runner = WhatsupGithub::Runner.new(Date.parse(date.to_s))
|
12
16
|
runner.run
|
13
17
|
end
|
@@ -11,8 +11,14 @@ module WhatsupGithub
|
|
11
11
|
|
12
12
|
include Singleton
|
13
13
|
|
14
|
+
@@filename = ''
|
15
|
+
|
16
|
+
def self.filename=(filename)
|
17
|
+
@@filename = filename
|
18
|
+
end
|
19
|
+
|
14
20
|
def initialize
|
15
|
-
@file =
|
21
|
+
@file = @@filename
|
16
22
|
@config = {}
|
17
23
|
end
|
18
24
|
|
@@ -64,6 +70,10 @@ module WhatsupGithub
|
|
64
70
|
def magic_word
|
65
71
|
read['magic_word']
|
66
72
|
end
|
73
|
+
|
74
|
+
def enterprise
|
75
|
+
read['enterprise']
|
76
|
+
end
|
67
77
|
end
|
68
78
|
end
|
69
79
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'singleton'
|
4
|
+
|
5
|
+
# Client authorization
|
6
|
+
module WhatsupGithub
|
7
|
+
# Create a singleton object for EnterpriseClient.
|
8
|
+
# Authorize with a GitHub Enterprise token from $WHATSUP_ENTERPRISE_ACCESS_TOKEN if available
|
9
|
+
# Otherwise, use credentials from ~/.netrc
|
10
|
+
class EnterpriseClient < Client
|
11
|
+
include Singleton
|
12
|
+
|
13
|
+
WHATSUP_ENTERPRISE_ACCESS_TOKEN = ENV['WHATSUP_ENTERPRISE_ACCESS_TOKEN']
|
14
|
+
private_constant :WHATSUP_ENTERPRISE_ACCESS_TOKEN
|
15
|
+
|
16
|
+
@@hostname = ''
|
17
|
+
|
18
|
+
def self.host=(hostname)
|
19
|
+
abort "ERROR: Set value for 'enterprise' in the whatsup_github configuration" if hostname.nil?
|
20
|
+
@@hostname = hostname
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
Octokit.configure do |c|
|
25
|
+
c.api_endpoint = "https://#{@@hostname}/api/v3/"
|
26
|
+
end
|
27
|
+
@client =
|
28
|
+
if WHATSUP_ENTERPRISE_ACCESS_TOKEN
|
29
|
+
Octokit::Client.new(access_token: WHATSUP_ENTERPRISE_ACCESS_TOKEN)
|
30
|
+
elsif File.exist? "#{ENV['HOME']}/.netrc"
|
31
|
+
Octokit::Client.new(netrc: true)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def search_issues(query)
|
36
|
+
@client.search_issues(query.gsub('enterprise:', ''))
|
37
|
+
end
|
38
|
+
|
39
|
+
def pull_request(repo, number)
|
40
|
+
@client.pull_request(repo.delete_prefix('enterprise:'), number)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/whatsup_github/pulls.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'octokit'
|
4
4
|
require_relative 'config_reader'
|
5
5
|
require_relative 'client'
|
6
|
+
require_relative 'enterprise_client'
|
6
7
|
|
7
8
|
module WhatsupGithub
|
8
9
|
# Gets issues found on GitHub by query
|
@@ -17,17 +18,17 @@ module WhatsupGithub
|
|
17
18
|
def data
|
18
19
|
pull_requests = []
|
19
20
|
filtered_numbers.each do |number|
|
20
|
-
pull_requests <<
|
21
|
+
pull_requests << if @repo.start_with? 'enterprise:'
|
22
|
+
enterprise_client.pull_request(@repo, number)
|
23
|
+
else
|
24
|
+
client.pull_request(@repo, number)
|
25
|
+
end
|
21
26
|
end
|
22
27
|
pull_requests
|
23
28
|
end
|
24
29
|
|
25
30
|
private
|
26
31
|
|
27
|
-
# def access_token
|
28
|
-
# credentials.dig 'github_token'
|
29
|
-
# end
|
30
|
-
|
31
32
|
def configuration
|
32
33
|
Config.instance
|
33
34
|
end
|
@@ -48,25 +49,40 @@ module WhatsupGithub
|
|
48
49
|
configuration.base_branch
|
49
50
|
end
|
50
51
|
|
51
|
-
# Authorize with a GitHub token from $WHATSUP_GITHUB_ACCESS_TOKEN if available
|
52
|
-
# Otherwise, use credentials from ~/.netrc
|
53
|
-
# Otherwise, continue as a Guest
|
54
52
|
def client
|
55
53
|
Client.instance
|
56
54
|
end
|
57
55
|
|
56
|
+
def enterprise_client
|
57
|
+
WhatsupGithub::EnterpriseClient.host = configuration.enterprise
|
58
|
+
EnterpriseClient.instance
|
59
|
+
end
|
60
|
+
|
58
61
|
def search_issues(label)
|
59
62
|
auto_paginate
|
60
|
-
query
|
61
|
-
puts "Searching on GitHub by query #{query}"
|
62
|
-
client.search_issues(query)
|
63
|
+
call_query query(label)
|
63
64
|
end
|
64
65
|
|
65
66
|
def search_issues_with_magic_word(label)
|
66
67
|
auto_paginate
|
67
|
-
|
68
|
+
call_query query_with_magic_word(label)
|
69
|
+
end
|
70
|
+
|
71
|
+
def call_query(query)
|
68
72
|
puts "Searching on GitHub by query #{query}"
|
69
|
-
|
73
|
+
if repo.start_with? 'enterprise:'
|
74
|
+
enterprise_client.search_issues(query)
|
75
|
+
else
|
76
|
+
client.search_issues(query)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def query(label)
|
81
|
+
"repo:#{repo} label:\"#{label}\" merged:>=#{since} base:#{base_branch} is:pull-request"
|
82
|
+
end
|
83
|
+
|
84
|
+
def query_with_magic_word(label)
|
85
|
+
query(label) + " \"#{magic_word}\" in:body"
|
70
86
|
end
|
71
87
|
|
72
88
|
def auto_paginate
|
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.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dima Shevtsov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: netrc
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- lib/whatsup_github/cli.rb
|
193
193
|
- lib/whatsup_github/client.rb
|
194
194
|
- lib/whatsup_github/config_reader.rb
|
195
|
+
- lib/whatsup_github/enterprise_client.rb
|
195
196
|
- lib/whatsup_github/generator.rb
|
196
197
|
- lib/whatsup_github/pulls.rb
|
197
198
|
- lib/whatsup_github/row.rb
|