Skip to content

Commit f77270c

Browse files
author
root
committed
Replace GitNotifications by Redmine watchers
1 parent d5519b9 commit f77270c

33 files changed

+238
-581
lines changed

app/controllers/repository_git_notifications_controller.rb

Lines changed: 0 additions & 69 deletions
This file was deleted.

app/models/concerns/gitolitable/notifications.rb

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,41 @@ module Gitolitable
22
module Notifications
33
extend ActiveSupport::Concern
44

5-
def notifier
6-
@notifier ||= ::GitNotifier.new(self)
5+
def mailing_list
6+
default_list + global_include_list - global_exclude_list
77
end
88

99

1010
def default_list
11-
notifier.default_list
11+
watcher_users.map(&:email_address).map(&:address)
1212
end
1313

1414

15-
def mail_mapping
16-
notifier.mail_mapping
15+
def global_include_list
16+
RedmineGitHosting::Config.gitolite_notify_global_include
1717
end
1818

1919

20-
def mailing_list
21-
notifier.mailing_list
20+
def global_exclude_list
21+
RedmineGitHosting::Config.gitolite_notify_global_exclude
2222
end
2323

2424

2525
def sender_address
26-
notifier.sender_address
26+
if extra.notification_sender.nil? || extra.notification_sender.empty?
27+
RedmineGitHosting::Config.gitolite_notify_global_sender_address
28+
else
29+
extra.notification_sender
30+
end
2731
end
2832

2933

3034
def email_prefix
31-
notifier.email_prefix
35+
if extra.notification_prefix.nil? || extra.notification_prefix.empty?
36+
RedmineGitHosting::Config.gitolite_notify_global_prefix
37+
else
38+
extra.notification_prefix
39+
end
3240
end
3341

3442
end

app/models/repository/xitolite.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class Repository::Xitolite < Repository::Git
1414

1515
# Relations
1616
has_one :extra, dependent: :destroy, foreign_key: 'repository_id', class_name: 'RepositoryGitExtra'
17-
has_one :git_notification, dependent: :destroy, foreign_key: 'repository_id', class_name: 'RepositoryGitNotification'
1817
has_many :mirrors, dependent: :destroy, foreign_key: 'repository_id', class_name: 'RepositoryMirror'
1918
has_many :post_receive_urls, dependent: :destroy, foreign_key: 'repository_id', class_name: 'RepositoryPostReceiveUrl'
2019
has_many :deployment_credentials, dependent: :destroy, foreign_key: 'repository_id', class_name: 'RepositoryDeploymentCredential'
@@ -26,6 +25,7 @@ class Repository::Xitolite < Repository::Git
2625
# Additionnal validations
2726
validate :valid_repository_options, on: :create
2827

28+
acts_as_watchable
2929

3030
class << self
3131

app/models/repository_git_extra.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ class RepositoryGitExtra < ActiveRecord::Base
2424
}
2525

2626
## Attributes
27-
attr_accessible :git_http, :git_daemon, :git_notify, :git_annex, :default_branch, :protected_branch, :public_repo, :key, :urls_order
27+
attr_accessible :git_http, :git_daemon, :git_notify, :git_annex, :default_branch, :protected_branch,
28+
:public_repo, :key, :urls_order, :notification_sender, :notification_prefix
2829

2930
## Relations
3031
belongs_to :repository
3132

3233
## Validations
33-
validates :repository_id, presence: true, uniqueness: true
34-
validates :git_http, presence: true, numericality: { only_integer: true }, inclusion: { in: [DISABLED, HTTP, HTTPS, BOTH] }
35-
validates :default_branch, presence: true
36-
validates :key, presence: true
34+
validates :repository_id, presence: true, uniqueness: true
35+
validates :git_http, presence: true, numericality: { only_integer: true }, inclusion: { in: [DISABLED, HTTP, HTTPS, BOTH] }
36+
validates :default_branch, presence: true
37+
validates :key, presence: true
38+
validates :notification_sender, format: { with: RedmineGitHosting::Validators::EMAIL_REGEX, allow_blank: true }
3739

3840
validate :validate_urls_order
3941

app/models/repository_git_notification.rb

Lines changed: 0 additions & 45 deletions
This file was deleted.

app/services/git_notifier.rb

Lines changed: 0 additions & 125 deletions
This file was deleted.

app/views/repositories/_edit_bottom.html.haml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
- if User.current.git_allowed_to?(:view_repository_deployment_credentials, @repository)
66
%li{ id: 'tab-repository_deployment_credentials' }= link_to label_with_icon(l(:label_deployment_credentials), 'fa-lock'), repository_deployment_credentials_path(@repository)
77

8-
- if User.current.git_allowed_to?(:view_repository_git_notifications, @repository)
9-
%li{ id: 'tab-repository_git_notifications' }= link_to label_with_icon(l(:label_git_notifications), 'fa-bullhorn'), repository_git_notifications_path(@repository)
10-
118
- if User.current.git_allowed_to?(:view_repository_mirrors, @repository)
129
%li{ id: 'tab-repository_mirrors' }= link_to label_with_icon(l(:label_repository_mirrors), 'fa-cloud-upload'), repository_mirrors_path(@repository)
1310

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<% content_for :header_tags do %>
2+
<%= javascript_include_tag 'repository_navigation' %>
3+
<% end %>
4+
5+
<%= watcher_link(@repository, User.current) %>
6+
|
7+
<%= link_to l(:label_statistics),
8+
{:action => 'stats', :id => @project, :repository_id => @repository.identifier_param},
9+
:class => 'icon icon-stats' if @repository.supports_all_revisions? %>
10+
11+
<%= form_tag({:action => controller.action_name,
12+
:id => @project,
13+
:repository_id => @repository.identifier_param,
14+
:path => to_path_param(@path),
15+
:rev => nil},
16+
{:method => :get, :id => 'revision_selector'}) do -%>
17+
<!-- Branches Dropdown -->
18+
<% if !@repository.branches.nil? && @repository.branches.length > 0 -%>
19+
| <%= l(:label_branch) %>:
20+
<%= select_tag :branch,
21+
options_for_select([''] + @repository.branches, @rev),
22+
:id => 'branch' %>
23+
<% end -%>
24+
25+
<% if !@repository.tags.nil? && @repository.tags.length > 0 -%>
26+
| <%= l(:label_tag) %>:
27+
<%= select_tag :tag,
28+
options_for_select([''] + @repository.tags, @rev),
29+
:id => 'tag' %>
30+
<% end -%>
31+
32+
<% if @repository.supports_all_revisions? %>
33+
| <%= l(:label_revision) %>:
34+
<%= text_field_tag 'rev', @rev, :size => 8 %>
35+
<% end %>
36+
<% end -%>

app/views/repositories/_sidebar.html.haml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
= link_to_repository(repo, @repository)
55
= link_to "(#{l(:label_settings)})", edit_repository_path(repo) if User.current.allowed_to?(:manage_repository, @project)
66

7+
- if User.current.allowed_to?(:add_issue_watchers, @project) || (@repository.watchers.present? && User.current.allowed_to?(:view_issue_watchers, @project))
8+
#watchers= render 'watchers/watchers', watched: @repository
9+
710
:javascript
811
$(document).ready(function() { $('#sidebar p').remove(); });

0 commit comments

Comments
 (0)