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
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: ruby
rvm:
- 2.1
- 2.2
- 2.3.0
sudo: false
cache: bundler
script:
- bundle exec rspec
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in errbit_github_plugin.gemspec
gemspec

gem 'errbit_plugin', :git => 'https://github.com/errbit/errbit_plugin.git'
gem 'errbit_plugin'
gem 'rspec'
gem 'guard'
gem 'guard-rspec'
Expand Down
1 change: 1 addition & 0 deletions errbit_github_plugin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency "activesupport"
end
18 changes: 18 additions & 0 deletions lib/errbit_github_plugin/issue_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,23 @@ def create_issue(title, body, user: {})
rescue Octokit::Unauthorized
raise ErrbitGithubPlugin::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password."
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'])
else
github_client = 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.
# ex: "https://github.com/octocat/Hello-World/issues/1347"
issue_number = url.split("/").last
issue = github_client.close_issue(repo, issue_number)
issue.html_url
rescue Octokit::Unauthorized
raise ErrbitGithubPlugin::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password."
end
end
end