#34: revert some changes, created UrlHelper
This commit is contained in:
parent
994f400af0
commit
72b2b637d1
|
@ -431,7 +431,7 @@ class BuildList < ActiveRecord::Base
|
|||
urpmi_list(nil, nil, false, save_to_repository.name)["#{build_for_platform.name}"]["#{arch.name}"]
|
||||
end
|
||||
|
||||
git_project_address = project.git_url user
|
||||
git_project_address = project.git_project_address user
|
||||
# git_project_address.gsub!(/^http:\/\/(0\.0\.0\.0|localhost)\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production?
|
||||
{
|
||||
:id => id,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
class Hook < ActiveRecord::Base
|
||||
include Modules::Models::WebHooks
|
||||
include Modules::Models::UrlHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
belongs_to :project
|
||||
|
||||
before_validation :cleanup_data
|
||||
|
@ -15,6 +17,7 @@ class Hook < ActiveRecord::Base
|
|||
def receive_issues(issue, action)
|
||||
pull = issue.pull_request
|
||||
return if action.to_sym == :create && pull
|
||||
default_url_options
|
||||
|
||||
payload = meta(issue.project, issue.user)
|
||||
base_params = {
|
||||
|
@ -34,7 +37,7 @@ class Hook < ActiveRecord::Base
|
|||
:commits => total_commits,
|
||||
:head => {:label => "#{pull.from_project.owner.uname}:#{pull.from_ref}"},
|
||||
:base => {:label => "#{repo_owner}:#{pull.to_ref}"},
|
||||
:html_url => "#{issue.project.html_url}/pull_requests/#{pull.serial_id}"
|
||||
:html_url => project_pull_request_url(pull.to_project, pull)
|
||||
)
|
||||
).to_json
|
||||
}
|
||||
|
@ -43,7 +46,7 @@ class Hook < ActiveRecord::Base
|
|||
:payload => payload.merge(
|
||||
:action => (issue.closed? ? 'closed' : 'opened'),
|
||||
:issue => base_params.merge(
|
||||
:html_url => "#{issue.project.html_url}/issues/#{issue.serial_id}"
|
||||
:html_url => project_issue_url(issue.project, issue)
|
||||
)
|
||||
).to_json
|
||||
}
|
||||
|
@ -52,6 +55,7 @@ class Hook < ActiveRecord::Base
|
|||
later :receive_issues, :queue => :notification
|
||||
|
||||
def receive_push(git_hook)
|
||||
default_url_options
|
||||
project = Project.find(git_hook['project']['project']['id'])
|
||||
user = User.find(git_hook['user']['user']['id'])
|
||||
payload = meta(project, user)
|
||||
|
@ -61,7 +65,7 @@ class Hook < ActiveRecord::Base
|
|||
payload.merge!(:before => oldrev, :after => newrev)
|
||||
if %w(delete create).exclude? change_type
|
||||
payload.merge!(
|
||||
:compare => "#{project.html_url}/diff/#{oldrev[0..6]}...#{newrev[0..6]}"
|
||||
:compare => diff_url(project, "#{oldrev[0..6]}...#{newrev[0..6]}")
|
||||
)
|
||||
if oldrev == newrev
|
||||
commits = [project.repo.commit(newrev)]
|
||||
|
@ -80,7 +84,7 @@ class Hook < ActiveRecord::Base
|
|||
:id => commit.id,
|
||||
:message => commit.message,
|
||||
:distinct => true,
|
||||
:url => "#{project.html_url}/commit/#{commit.id}",
|
||||
:url => commit_url(project, commit),
|
||||
:removed => files[:removed],
|
||||
:added => files[:added],
|
||||
:modified => files[:modified],
|
||||
|
@ -106,7 +110,7 @@ class Hook < ActiveRecord::Base
|
|||
{
|
||||
:repository => {
|
||||
:name => project.name,
|
||||
:url => project.html_url,
|
||||
:url => project_url(project),
|
||||
:owner => { :login => project.owner.uname }
|
||||
},
|
||||
:sender => {:login => user.uname},
|
||||
|
|
|
@ -80,6 +80,7 @@ class Project < ActiveRecord::Base
|
|||
include Modules::Models::Owner
|
||||
include Modules::Models::Git
|
||||
include Modules::Models::Wiki
|
||||
include Modules::Models::UrlHelper
|
||||
|
||||
class << self
|
||||
def find_by_owner_and_name(owner_name, project_name)
|
||||
|
@ -138,20 +139,13 @@ class Project < ActiveRecord::Base
|
|||
owner == user
|
||||
end
|
||||
|
||||
def html_url(auth_user = nil)
|
||||
host ||= EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host]
|
||||
protocol = APP_CONFIG['mailer_https_url'] ? "https" : "http" rescue "http"
|
||||
opts = {:host => host, :protocol => protocol}
|
||||
opts.merge!({:user => auth_user.authentication_token, :password => ''}) if auth_user && !self.public?
|
||||
Rails.application.routes.url_helpers.project_url(self.owner.uname, self.name, opts)
|
||||
def git_project_address auth_user
|
||||
opts = default_url_options
|
||||
opts.merge!({:user => auth_user.authentication_token, :password => ''}) unless self.public?
|
||||
Rails.application.routes.url_helpers.project_url(self.owner.uname, self.name, opts) + '.git'
|
||||
#path #share by NFS
|
||||
end
|
||||
|
||||
def git_url(auth_user)
|
||||
html_url(auth_user) + '.git'
|
||||
end
|
||||
|
||||
|
||||
def build_for(platform, repository_id, user, arch = Arch.find_by_name('i586'), auto_publish = false, mass_build_id = nil, priority = 0)
|
||||
# Select main and project platform repository(contrib, non-free and etc)
|
||||
# If main does not exist, will connect only project platform repository
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
module Modules::Models::UrlHelper
|
||||
def default_url_options
|
||||
host ||= EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host]
|
||||
protocol ||= APP_CONFIG['mailer_https_url'] ? 'https' : 'http' rescue 'http'
|
||||
{:host => host, :protocol => protocol}
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue