whatsup_github 0.5.0 → 1.0.0
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 +2 -1
- 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 +35 -0
- data/lib/whatsup_github/pulls.rb +30 -12
- 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: 6011fb20af5b86f2b85e7355a07bed05ee27925a4da730016e9235e5fc617b31
|
4
|
+
data.tar.gz: 06606d117ab0023ab99db64df32a8fb46860a7b9f225f5ab8ddfbc7b62f21423
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a702fd6f297fa9ac740166b873430da82ea1a9fbd53c71668987e26a9a616a8a53582491225fced72ce1e541273c0f0094339ca1ad0d4d6daefc089c4e1d5b08
|
7
|
+
data.tar.gz: f49151e889c66674200a0752c7a6b2f2e2f2c179486339b5e6e3f420cd822218f10ff9c6d8273a658ec02bec9eb6152c57a9ae1200b3623f582cd7d8b3c51d02
|
@@ -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
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,35 @@
|
|
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
|
+
end
|
35
|
+
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
|
@@ -24,10 +25,6 @@ module WhatsupGithub
|
|
24
25
|
|
25
26
|
private
|
26
27
|
|
27
|
-
# def access_token
|
28
|
-
# credentials.dig 'github_token'
|
29
|
-
# end
|
30
|
-
|
31
28
|
def configuration
|
32
29
|
Config.instance
|
33
30
|
end
|
@@ -48,25 +45,46 @@ module WhatsupGithub
|
|
48
45
|
configuration.base_branch
|
49
46
|
end
|
50
47
|
|
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
48
|
def client
|
55
49
|
Client.instance
|
56
50
|
end
|
57
51
|
|
52
|
+
def enterprise_client
|
53
|
+
WhatsupGithub::EnterpriseClient.host = configuration.enterprise
|
54
|
+
EnterpriseClient.instance
|
55
|
+
end
|
56
|
+
|
58
57
|
def search_issues(label)
|
59
58
|
auto_paginate
|
60
|
-
query
|
61
|
-
puts "Searching on GitHub by query #{query}"
|
62
|
-
client.search_issues(query)
|
59
|
+
call_query query(label)
|
63
60
|
end
|
64
61
|
|
65
62
|
def search_issues_with_magic_word(label)
|
66
63
|
auto_paginate
|
67
|
-
|
64
|
+
call_query query_with_magic_word(label)
|
65
|
+
end
|
66
|
+
|
67
|
+
def call_query(query)
|
68
68
|
puts "Searching on GitHub by query #{query}"
|
69
|
-
|
69
|
+
if repo.start_with? 'enterprise:'
|
70
|
+
enterprise_client.search_issues(
|
71
|
+
enterprise_query(query)
|
72
|
+
)
|
73
|
+
else
|
74
|
+
client.search_issues(query)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def enterprise_query(query)
|
79
|
+
query.gsub('enterprise:', '')
|
80
|
+
end
|
81
|
+
|
82
|
+
def query(label)
|
83
|
+
"repo:#{repo} label:\"#{label}\" merged:>=#{since} base:#{base_branch} is:pull-request"
|
84
|
+
end
|
85
|
+
|
86
|
+
def query_with_magic_word(label)
|
87
|
+
query(label) + " \"#{magic_word}\" in:body"
|
70
88
|
end
|
71
89
|
|
72
90
|
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.0
|
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-17 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
|