Skip to content
This repository was archived by the owner on Apr 11, 2026. It is now read-only.

Commit 8756a87

Browse files
committed
Fix the bug with non-working membership (#25)
* Fix the bug with non-working membership - Create Client as a Singleton class - Remove Membership class, delegate to an instance method of Client * Add linting - Add SuperLinter workflow - Add linter config for Ruby
1 parent 61e8a46 commit 8756a87

9 files changed

Lines changed: 118 additions & 32 deletions

File tree

.github/linters/.ruby-lint.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
#######################
3+
# Rubocop Config file #
4+
#######################
5+
6+
inherit_gem:
7+
rubocop-github:
8+
- config/default.yml
9+
10+
Style/StringLiterals:
11+
EnforcedStyle: single_quotes

.github/workflows/linter.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
###########################
3+
###########################
4+
## Linter GitHub Actions ##
5+
###########################
6+
###########################
7+
name: Lint Code Base
8+
9+
#
10+
# Documentation:
11+
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
12+
#
13+
14+
###################################
15+
# Start the job on a pull request #
16+
###################################
17+
on:
18+
pull_request
19+
20+
###############
21+
# Set the Job #
22+
###############
23+
jobs:
24+
super-lint:
25+
# Set the agent to run on
26+
runs-on: ubuntu-latest
27+
28+
##################
29+
# Load all steps #
30+
##################
31+
steps:
32+
##########################
33+
# Checkout the code base #
34+
##########################
35+
- name: Checkout Code
36+
uses: actions/checkout@v2
37+
with:
38+
# Full git history is needed to get a proper list of changed files within `super-linter`
39+
fetch-depth: 0
40+
41+
################################
42+
# Run Linter against code base #
43+
################################
44+
- name: Lint Code Base
45+
uses: github/super-linter@v3
46+
env:
47+
VALIDATE_ALL_CODEBASE: false
48+
DEFAULT_BRANCH: main

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 0.4.2
4+
5+
Fixes:
6+
7+
- Fixed a bug with non-working membership
8+
9+
Maintenance:
10+
11+
- Added code linting
12+
313
## 0.4.1
414

515
- Added authentication via an environment variable `WHATSUP_GITHUB_ACCESS_TOKEN`

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
whatsup_github (0.4.1)
4+
whatsup_github (0.4.2)
55
netrc (~> 0.11)
66
octokit (~> 4.20)
77
thor (~> 1.1)

lib/whatsup_github/client.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# frozen_string_literal: true
2+
3+
require 'singleton'
4+
5+
# Client authorization
6+
module WhatsupGithub
7+
# Create a singleton object for Client.
8+
# Authorize with a GitHub token from $WHATSUP_GITHUB_ACCESS_TOKEN if available
9+
# Otherwise, use credentials from ~/.netrc
10+
# Otherwise, continue as a Guest
11+
class Client
12+
include Singleton
13+
14+
WHATSUP_GITHUB_ACCESS_TOKEN = ENV['WHATSUP_GITHUB_ACCESS_TOKEN']
15+
private_constant :WHATSUP_GITHUB_ACCESS_TOKEN
16+
17+
def initialize
18+
@client =
19+
if WHATSUP_GITHUB_ACCESS_TOKEN
20+
Octokit::Client.new(access_token: WHATSUP_GITHUB_ACCESS_TOKEN)
21+
elsif File.exist? "#{ENV['HOME']}/.netrc"
22+
Octokit::Client.new(netrc: true)
23+
else
24+
Octokit::Client.new
25+
end
26+
end
27+
28+
def search_issues(query)
29+
@client.search_issues(query)
30+
end
31+
32+
def pull_request(repo, number)
33+
@client.pull_request(repo, number)
34+
end
35+
36+
def org_members(org)
37+
@client.org_members(org)
38+
end
39+
end
40+
end

lib/whatsup_github/members.rb

Lines changed: 0 additions & 18 deletions
This file was deleted.

lib/whatsup_github/pulls.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'octokit'
44
require_relative 'config_reader'
5+
require_relative 'client'
56

67
module WhatsupGithub
78
# Gets issues found on GitHub by query
@@ -51,16 +52,7 @@ def base_branch
5152
# Otherwise, use credentials from ~/.netrc
5253
# Otherwise, continue as a Guest
5354
def client
54-
return @client if @client
55-
56-
@client =
57-
if ENV['WHATSUP_GITHUB_ACCESS_TOKEN']
58-
Octokit::Client.new(access_token: ENV['WHATSUP_GITHUB_ACCESS_TOKEN'])
59-
elsif File.exist? "#{ENV['HOME']}/.netrc"
60-
Octokit::Client.new(netrc: true)
61-
else
62-
Octokit::Client.new
63-
end
55+
Client.instance
6456
end
6557

6658
def search_issues(label)

lib/whatsup_github/row_collector.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require_relative 'row'
44
require_relative 'pulls'
55
require_relative 'config_reader'
6-
require_relative 'members'
76

87
module WhatsupGithub
98
# Creates Row objects for the future table
@@ -82,7 +81,7 @@ def pulls(repo)
8281
def load_members
8382
return if @members
8483

85-
@members = Members.new(config.membership).members
84+
@members = client.org_members(config.membership)
8685
end
8786

8887
def member_logins
@@ -93,5 +92,9 @@ def member_logins
9392
def config
9493
Config.instance
9594
end
95+
96+
def client
97+
Client.instance
98+
end
9699
end
97100
end

lib/whatsup_github/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module WhatsupGithub
4-
VERSION = '0.4.1'
4+
VERSION = '0.4.2'
55
end

0 commit comments

Comments
 (0)