Commit 4a4ad098fcfc7fdd2176bf19bb2b4435fa9d2f28

Authored by Nathan Broadbent
2 parents a45643a3 e0f0c297
Exists in master and in 1 other branch production

Merge branch 'master' of https://github.com/shukydvir/errbit into shukydvir-master

Conflicts:
	app/helpers/apps_helper.rb
	app/views/apps/index.html.haml
app/helpers/apps_helper.rb
... ... @@ -21,6 +21,11 @@ module AppsHelper
21 21 @any_notification_services
22 22 end
23 23  
  24 + def any_bitbucket_repos?
  25 + detect_any_apps_with_attributes unless @any_bitbucket_repos
  26 + @any_bitbucket_repos
  27 + end
  28 +
24 29 def any_issue_trackers?
25 30 detect_any_apps_with_attributes unless @any_issue_trackers
26 31 @any_issue_trackers
... ... @@ -34,9 +39,11 @@ module AppsHelper
34 39 private
35 40  
36 41 def detect_any_apps_with_attributes
37   - @any_github_repos = @any_issue_trackers = @any_deploys = @any_notification_services = false
  42 + @any_github_repos = @any_issue_trackers = @any_deploys = @any_bitbucket_repos = @any_notification_services = false
  43 +
38 44 @apps.each do |app|
39 45 @any_github_repos ||= app.github_repo?
  46 + @any_bitbucket_repos ||= app.bitbucket_repo?
40 47 @any_issue_trackers ||= app.issue_tracker_configured?
41 48 @any_deploys ||= !!app.last_deploy_at
42 49 @any_notification_services ||= app.notification_service_configured?
... ...
app/helpers/notices_helper.rb
... ... @@ -12,6 +12,7 @@ module NoticesHelper
12 12 text = capture_haml(&block)
13 13 if in_app_backtrace_line?(line)
14 14 return link_to_github(app, line, text) if app.github_repo?
  15 + return link_to_bitbucket(app, line, text) if app.bitbucket_repo?
15 16 if app.issue_tracker && app.issue_tracker.respond_to?(:url_to_file)
16 17 # Return link to file on tracker if issue tracker supports this
17 18 return link_to_issue_tracker_file(app, line, text)
... ... @@ -30,6 +31,12 @@ module NoticesHelper
30 31 link_to(text || file_name, href, :target => '_blank')
31 32 end
32 33  
  34 + def link_to_bitbucket(app, line, text = nil)
  35 + file_name, file_path = filepath_parts(line['file'])
  36 + href = "%s#cl-%s" % [app.bitbucket_url_to_file(file_path), line['number']]
  37 + link_to(text || file_name, href, :target => '_blank')
  38 + end
  39 +
33 40 def link_to_issue_tracker_file(app, line, text = nil)
34 41 file_name, file_path = filepath_parts(line['file'])
35 42 href = app.issue_tracker.url_to_file(file_path, line['number'])
... ...
app/models/app.rb
... ... @@ -5,6 +5,7 @@ class App
5 5 field :name, :type => String
6 6 field :api_key
7 7 field :github_repo
  8 + field :bitbucket_repo
8 9 field :resolve_errs_on_deploy, :type => Boolean, :default => false
9 10 field :notify_all_users, :type => Boolean, :default => false
10 11 field :notify_on_errs, :type => Boolean, :default => true
... ... @@ -118,6 +119,18 @@ class App
118 119 "#{github_url}/blob/master#{file}"
119 120 end
120 121  
  122 + def bitbucket_repo?
  123 + self.bitbucket_repo.present?
  124 + end
  125 +
  126 + def bitbucket_url
  127 + "https://bitbucket.org/#{bitbucket_repo}" if bitbucket_repo?
  128 + end
  129 +
  130 + def bitbucket_url_to_file(file)
  131 + "#{bitbucket_url}/src/master#{file}"
  132 + end
  133 +
121 134  
122 135 def issue_tracker_configured?
123 136 !!(issue_tracker && issue_tracker.class < IssueTracker && issue_tracker.project_id.present?)
... ...
app/views/apps/_fields.html.haml
... ... @@ -7,6 +7,9 @@
7 7 %div
8 8 = f.label :github_repo
9 9 = f.text_field :github_repo, :placeholder => "errbit/errbit from https://github.com/errbit/errbit"
  10 +%div
  11 + = f.label :bitbucket_repo
  12 + = f.text_field :bitbucket_repo, :placeholder => "errbit/errbit from https://bitbucket.org/errbit/errbit"
10 13  
11 14 %fieldset
12 15 %legend Notifications
... ...
app/views/apps/index.html.haml
... ... @@ -6,8 +6,8 @@
6 6 %thead
7 7 %tr
8 8 %th Name
9   - - if any_github_repos?
10   - %th GitHub Repo
  9 + - if any_github_repos? || any_bitbucket_repos?
  10 + %th Repository
11 11 - if any_notification_services?
12 12 %th Notification Service
13 13 - if any_issue_trackers?
... ... @@ -19,10 +19,12 @@
19 19 - @apps.each do |app|
20 20 %tr
21 21 %td.name= link_to app.name, app_path(app)
22   - - if any_github_repos?
  22 + - if any_github_repos? or any_bitbucket_repos?
23 23 %td.github_repo
24 24 - if app.github_repo?
25 25 = link_to(app.github_repo, app.github_url, :target => '_blank')
  26 + - if app.bitbucket_repo?
  27 + = link_to(app.bitbucket_repo, app.bitbucket_url, :target => '_blank')
26 28 - if any_notification_services?
27 29 %td.notification_service
28 30 - if app.notification_service_configured?
... ...
config/unicorn.rb
1 1 # http://michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-single-heroku-dyno-with-the-new-celadon-cedar-stack/
2 2  
3 3 worker_processes 3 # amount of unicorn workers to spin up
4   -timeout 30 # restarts workers that hang for 30 seconds
5 4 \ No newline at end of file
  5 +timeout 30 # restarts workers that hang for 30 seconds
  6 +preload_app true
6 7 \ No newline at end of file
... ...