Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

gemspec

gem "simplecov", require: false
gem "standard"
46 changes: 46 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ GEM
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.3)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
Expand All @@ -40,15 +41,25 @@ GEM
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.10.2)
language_server-protocol (3.17.0.4)
lint_roller (1.1.0)
logger (1.7.0)
minitest (5.25.5)
net-http (0.6.0)
uri
octokit (9.2.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
parallel (1.26.3)
parser (3.3.7.4)
ast (~> 2.4.1)
racc
prism (1.4.0)
public_suffix (6.0.1)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.10.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand All @@ -62,6 +73,25 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.2)
rubocop (1.75.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.44.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.44.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-performance (1.25.0)
lint_roller (~> 1.1)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
ruby-progressbar (1.13.0)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
Expand All @@ -72,8 +102,23 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
standard (1.49.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.75.2)
standard-custom (~> 1.0.0)
standard-performance (~> 1.8)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.8.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.25.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
uri (1.0.3)

PLATFORMS
Expand All @@ -95,6 +140,7 @@ DEPENDENCIES
rake
rspec
simplecov
standard

BUNDLED WITH
2.6.7
37 changes: 18 additions & 19 deletions errbit_github_plugin.gemspec
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
# frozen_string_literal: true

lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'errbit_github_plugin/version'
require "errbit_github_plugin/version"

Gem::Specification.new do |spec|
spec.name = 'errbit_github_plugin'
spec.version = ErrbitGithubPlugin::VERSION
spec.authors = ['Stephen Crosby']
spec.email = ['[email protected]']
spec.name = "errbit_github_plugin"
spec.version = ErrbitGithubPlugin::VERSION
spec.authors = ["Stephen Crosby"]
spec.email = ["[email protected]"]

spec.description = %q{GitHub integration for Errbit}
spec.summary = %q{GitHub integration for Errbit}
spec.homepage = 'https://github.com/errbit/errbit_github_plugin'
spec.license = 'MIT'
spec.description = "GitHub integration for Errbit"
spec.summary = "GitHub integration for Errbit"
spec.homepage = "https://github.com/errbit/errbit_github_plugin"
spec.license = "MIT"

spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency 'errbit_plugin'
spec.add_dependency 'octokit'
spec.add_dependency "errbit_plugin"
spec.add_dependency "octokit"

spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'activesupport'
spec.add_development_dependency "rspec"
spec.add_development_dependency "rake"
spec.add_development_dependency "activesupport"
end
8 changes: 4 additions & 4 deletions lib/errbit_github_plugin.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# frozen_string_literal: true

require "errbit_github_plugin/version"
require 'errbit_github_plugin/error'
require 'errbit_github_plugin/issue_tracker'
require "errbit_github_plugin/error"
require "errbit_github_plugin/issue_tracker"

module ErrbitGithubPlugin
def self.root
File.expand_path '../..', __FILE__
File.expand_path "../..", __FILE__
end

def self.read_static_file(file)
File.read(File.join(self.root, 'static', file))
File.read(File.join(root, "static", file))
end
end

Expand Down
51 changes: 27 additions & 24 deletions lib/errbit_github_plugin/issue_tracker.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# frozen_string_literal: true

require 'octokit'
require "octokit"

module ErrbitGithubPlugin
class IssueTracker < ErrbitPlugin::IssueTracker
LABEL = "github"

LABEL = 'github'

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

FIELDS = {
username: {
Expand All @@ -37,13 +36,13 @@ def self.fields
def self.icons
@icons ||= {
create: [
'image/png', ErrbitGithubPlugin.read_static_file('github_create.png')
"image/png", ErrbitGithubPlugin.read_static_file("github_create.png")
],
goto: [
'image/png', ErrbitGithubPlugin.read_static_file('github_goto.png'),
"image/png", ErrbitGithubPlugin.read_static_file("github_goto.png")
],
inactive: [
'image/png', ErrbitGithubPlugin.read_static_file('github_inactive.png'),
"image/png", ErrbitGithubPlugin.read_static_file("github_inactive.png")
]
}
end
Expand All @@ -58,11 +57,11 @@ def url

def errors
errors = []
if self.class.fields.detect {|f| options[f[0]].blank? }
errors << [:base, 'You must specify your GitHub username and password']
if self.class.fields.detect { |f| options[f[0]].blank? }
errors << [:base, "You must specify your GitHub username and password"]
end
if repo.blank?
errors << [:base, 'You must specify your GitHub repository url.']
errors << [:base, "You must specify your GitHub repository url."]
end
errors
end
Expand All @@ -72,12 +71,14 @@ def repo
end

def create_issue(title, body, user: {})
if user['github_login'] && user['github_oauth_token']
github_client = Octokit::Client.new(
login: user['github_login'], access_token: user['github_oauth_token'])
github_client = if user["github_login"] && user["github_oauth_token"]
Octokit::Client.new(
login: user["github_login"], access_token: user["github_oauth_token"]
)
else
github_client = Octokit::Client.new(
login: options['username'], password: options['password'])
Octokit::Client.new(
login: options["username"], password: options["password"]
)
end
issue = github_client.create_issue(repo, title, body)
issue.html_url
Expand All @@ -86,12 +87,14 @@ def create_issue(title, body, user: {})
end

def close_issue(url, user: {})
if user['github_login'] && user['github_oauth_token']
github_client = Octokit::Client.new(
login: user['github_login'], access_token: user['github_oauth_token'])
github_client = if user["github_login"] && user["github_oauth_token"]
Octokit::Client.new(
login: user["github_login"], access_token: user["github_oauth_token"]
)
else
github_client = Octokit::Client.new(
login: options['username'], password: options['password'])
Octokit::Client.new(
login: options["username"], password: options["password"]
)
end
# It would be better to get the number from issue.number when we create the issue,
# however, since we only have the url, get the number from it.
Expand Down
2 changes: 1 addition & 1 deletion lib/errbit_github_plugin/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ErrbitGithubPlugin
VERSION = '0.4.0'
VERSION = "0.4.0"
end
Loading