diff --git a/.gitignore b/.gitignore index 6bee5f3..4819dc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -ruby_git_issue-1.0.2.gem \ No newline at end of file +ruby_git_issue-* \ No newline at end of file diff --git a/lib/ruby_git_issue.rb b/lib/ruby_git_issue.rb index 98ad811..50e5f81 100644 --- a/lib/ruby_git_issue.rb +++ b/lib/ruby_git_issue.rb @@ -30,8 +30,13 @@ def client # column_id ## Integer => Get column id from project and its columns # column_id can be blank as well. Issue will not be assigned to and project column if column_id is blank def generate_issue(column_id=nil) - issue_data = client.create_issue("#{organization}/#{repo}", issue_options[:title], compose_body(exception_data, request), issue_options) - add_issue_to_project(issue_data, column_id) unless column_id.nil? + existing_issue = client.list_issues("#{organization}/#{repo}").select{|issue| issue[:title] == issue_options[:title]}.try(:first) + if existing_issue.nil? + issue_data = client.create_issue("#{organization}/#{repo}", issue_options[:title], compose_body(exception_data, request), issue_options) + add_issue_to_project(issue_data, column_id) unless column_id.nil? + else + client.add_comment("#{organization}/#{repo}", existing_issue.number, compose_body(exception_data, request)) + end end # Get Github project based on the organization passed while initializing client diff --git a/ruby_git_issue.gemspec b/ruby_git_issue.gemspec index d2db53d..6b7fd39 100644 --- a/ruby_git_issue.gemspec +++ b/ruby_git_issue.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |gem| gem.name = 'ruby_git_issue' - gem.version = '1.0.2' + gem.version = '1.1.0' gem.date = '2020-05-11' gem.summary = "Ruby Git Issue on exception generation" gem.description = "When rails throws excpetion, this gem will create issue and if project available, it will create project, assign developer and set tags if availabe"