diff --git a/Gemfile b/Gemfile index 4f458f9..ec966e6 100644 --- a/Gemfile +++ b/Gemfile @@ -37,7 +37,7 @@ gem 'ruby-fogbugz', :require => 'fogbugz' # Github Issues gem 'octokit', '~> 1.0.0' # Gitlab -gem 'gitlab' +gem 'gitlab', :git => 'git://github.com/NARKOZ/gitlab' # Bitbucket Issues gem 'bitbucket_rest_api' diff --git a/Gemfile.lock b/Gemfile.lock index fd197f3..3aea1e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,10 @@ +GIT + remote: git://github.com/NARKOZ/gitlab + revision: e4d7dd7dd4be587e44de388eb64d164cab5d464f + specs: + gitlab (2.2.0) + httparty + GEM remote: http://rubygems.org/ specs: @@ -99,8 +106,6 @@ GEM ffi (1.1.4) foreman (0.60.2) thor (>= 0.13.6) - gitlab (2.1.0) - httparty haml (3.1.6) happymapper (0.4.0) libxml-ruby (~> 2.0) diff --git a/app/models/issue_trackers/gitlab_tracker.rb b/app/models/issue_trackers/gitlab_tracker.rb index 3c469a0..1e18cf5 100644 --- a/app/models/issue_trackers/gitlab_tracker.rb +++ b/app/models/issue_trackers/gitlab_tracker.rb @@ -10,7 +10,7 @@ if defined? Gitlab :placeholder => "API Token for your account" }], [:project_id, { - :label => "Ticket Project Short Name / ID", + :label => "Ticket Project ID (use Number)", :placeholder => "Gitlab Project where issues will be created" }] ] @@ -23,19 +23,25 @@ if defined? Gitlab def create_issue(problem, reported_by = nil) Gitlab.configure do |config| - config.endpoint = "#{account}/api/v2" + config.endpoint = "#{account}/api/v3" config.private_token = api_token config.user_agent = 'Errbit User Agent' end title = issue_title problem - description = body_template.result(binding) - Gitlab.create_issue(project_id, title, { :description => description, :labels => "errbit" } ) + description_summary = summary_template.result(binding) + description_body = body_template.result(binding) + ticket = Gitlab.create_issue(project_id, title, { :description => description_summary, :labels => "errbit" } ) + Gitlab.create_issue_note(project_id, ticket.id, description_body) end + def summary_template + @@summary_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/gitlab_summary.txt.erb").gsub(/^\s*/, '')) + + end def body_template @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/gitlab_body.txt.erb").gsub(/^\s*/, '')) end - + def url "#{account}/#{project_id}/issues" end diff --git a/app/views/issue_trackers/gitlab_body.txt.erb b/app/views/issue_trackers/gitlab_body.txt.erb index 3c01a35..61d7a4b 100644 --- a/app/views/issue_trackers/gitlab_body.txt.erb +++ b/app/views/issue_trackers/gitlab_body.txt.erb @@ -1,20 +1,4 @@ -[See this exception on Errbit](<%= app_problem_url problem.app, problem %> "See this exception on Errbit") <% if notice = problem.notices.first %> -# <%= notice.message %> # -## Summary ## -<% if notice.request['url'].present? %> - ### URL ### - [<%= notice.request['url'] %>](<%= notice.request['url'] %>)" -<% end %> -### Where ### -<%= notice.where %> - -### Occured ### -<%= notice.created_at.to_s(:micro) %> - -### Similar ### -<%= (notice.problem.notices_count - 1).to_s %> - ## Params ## ``` <%= pretty_hash(notice.params) %> -- libgit2 0.21.2