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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfff3f017c4ab987bfb23086782ad4ca233bbc3f8216eece2bf518b7164f71c7
4
- data.tar.gz: 20b3555c3511a364c86c5dc7a83e6d934ab12a0fee54573b6d6cee5090ad9c49
3
+ metadata.gz: 6011fb20af5b86f2b85e7355a07bed05ee27925a4da730016e9235e5fc617b31
4
+ data.tar.gz: 06606d117ab0023ab99db64df32a8fb46860a7b9f225f5ab8ddfbc7b62f21423
5
5
  SHA512:
6
- metadata.gz: 6e4604bf0cab9e466e0c30834ae8ed4e454f9a3229e25fc4ed3c5dbd33db89919b3f280a4001f794c7edec2d3ce4ac5e2f3a7185db34b976bb187fbf5f7436b1
7
- data.tar.gz: 29e3adc0ea5190d4ae912a00778e66db83889825963641269a954a2cd6d8f056dde54bbda0c164b026744f3dda5d2e0b0471d1d42804b19e94f5ecf4e0dcf4fa
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- whatsup_github (0.5.0)
4
+ whatsup_github (1.0.0)
5
5
  netrc (~> 0.11)
6
6
  octokit (~> 6.0)
7
7
  thor (~> 1.2)
@@ -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 regex `\d\.`.
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
- Memebership of the contributor in a configured organization.
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 dshevtsov
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 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.
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
 
@@ -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
 
@@ -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 = '.whatsup.yml'
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
@@ -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 = "repo:#{repo} label:\"#{label}\" merged:>=#{since} base:#{base_branch} is:pull-request"
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
- query = "repo:#{repo} label:\"#{label}\" merged:>=#{since} base:#{base_branch} \"#{magic_word}\" in:body is:pull-request"
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
- client.search_issues(query)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WhatsupGithub
4
- VERSION = '0.5.0'
4
+ VERSION = '1.0.0'
5
5
  end
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.5.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-04 00:00:00.000000000 Z
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