Skip to content

Commit 678ab19

Browse files
committed
Standard
1 parent a57f14f commit 678ab19

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

lib/errbit_github_plugin/issue_tracker.rb

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
# frozen_string_literal: true
22

3-
require 'octokit'
3+
require "octokit"
44

55
module ErrbitGithubPlugin
66
class IssueTracker < ErrbitPlugin::IssueTracker
7+
LABEL = "github"
78

8-
LABEL = 'github'
9-
10-
NOTE = 'Please configure your github repository in the <strong>GITHUB ' \
11-
'REPO</strong> field above.<br/> Instead of providing your ' \
12-
'username & password, you can link your Github account to your ' \
13-
'user profile, and allow Errbit to create issues using your ' \
14-
'OAuth token.'
9+
NOTE = "Please configure your github repository in the <strong>GITHUB " \
10+
"REPO</strong> field above.<br/> Instead of providing your " \
11+
"username & password, you can link your Github account to your " \
12+
"user profile, and allow Errbit to create issues using your " \
13+
"OAuth token."
1514

1615
FIELDS = {
1716
username: {
@@ -37,13 +36,13 @@ def self.fields
3736
def self.icons
3837
@icons ||= {
3938
create: [
40-
'image/png', ErrbitGithubPlugin.read_static_file('github_create.png')
39+
"image/png", ErrbitGithubPlugin.read_static_file("github_create.png")
4140
],
4241
goto: [
43-
'image/png', ErrbitGithubPlugin.read_static_file('github_goto.png'),
42+
"image/png", ErrbitGithubPlugin.read_static_file("github_goto.png")
4443
],
4544
inactive: [
46-
'image/png', ErrbitGithubPlugin.read_static_file('github_inactive.png'),
45+
"image/png", ErrbitGithubPlugin.read_static_file("github_inactive.png")
4746
]
4847
}
4948
end
@@ -58,11 +57,11 @@ def url
5857

5958
def errors
6059
errors = []
61-
if self.class.fields.detect {|f| options[f[0]].blank? }
62-
errors << [:base, 'You must specify your GitHub username and password']
60+
if self.class.fields.detect { |f| options[f[0]].blank? }
61+
errors << [:base, "You must specify your GitHub username and password"]
6362
end
6463
if repo.blank?
65-
errors << [:base, 'You must specify your GitHub repository url.']
64+
errors << [:base, "You must specify your GitHub repository url."]
6665
end
6766
errors
6867
end
@@ -72,12 +71,14 @@ def repo
7271
end
7372

7473
def create_issue(title, body, user: {})
75-
if user['github_login'] && user['github_oauth_token']
76-
github_client = Octokit::Client.new(
77-
login: user['github_login'], access_token: user['github_oauth_token'])
74+
github_client = if user["github_login"] && user["github_oauth_token"]
75+
Octokit::Client.new(
76+
login: user["github_login"], access_token: user["github_oauth_token"]
77+
)
7878
else
79-
github_client = Octokit::Client.new(
80-
login: options['username'], password: options['password'])
79+
Octokit::Client.new(
80+
login: options["username"], password: options["password"]
81+
)
8182
end
8283
issue = github_client.create_issue(repo, title, body)
8384
issue.html_url
@@ -86,12 +87,14 @@ def create_issue(title, body, user: {})
8687
end
8788

8889
def close_issue(url, user: {})
89-
if user['github_login'] && user['github_oauth_token']
90-
github_client = Octokit::Client.new(
91-
login: user['github_login'], access_token: user['github_oauth_token'])
90+
github_client = if user["github_login"] && user["github_oauth_token"]
91+
Octokit::Client.new(
92+
login: user["github_login"], access_token: user["github_oauth_token"]
93+
)
9294
else
93-
github_client = Octokit::Client.new(
94-
login: options['username'], password: options['password'])
95+
Octokit::Client.new(
96+
login: options["username"], password: options["password"]
97+
)
9598
end
9699
# It would be better to get the number from issue.number when we create the issue,
97100
# however, since we only have the url, get the number from it.

0 commit comments

Comments
 (0)