2009-02-11 01:03:25 +03:00
|
|
|
# Redmine - project management software
|
2011-05-25 08:39:33 +04:00
|
|
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
2007-04-01 23:43:59 +04:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-05-25 08:39:33 +04:00
|
|
|
#
|
2007-04-01 23:43:59 +04:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2011-05-25 08:39:33 +04:00
|
|
|
#
|
2007-04-01 23:43:59 +04:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
class SysController < ActionController::Base
|
2009-02-11 01:03:25 +03:00
|
|
|
before_filter :check_enabled
|
2011-05-25 08:39:33 +04:00
|
|
|
|
2009-02-11 01:03:25 +03:00
|
|
|
def projects
|
2012-02-03 03:26:54 +04:00
|
|
|
p = Project.active.has_module(:repository).find(
|
|
|
|
:all,
|
|
|
|
:include => :repository,
|
|
|
|
:order => "#{Project.table_name}.identifier"
|
|
|
|
)
|
2011-11-27 21:30:28 +04:00
|
|
|
# extra_info attribute from repository breaks activeresource client
|
2012-02-03 03:26:54 +04:00
|
|
|
render :xml => p.to_xml(
|
|
|
|
:only => [:id, :identifier, :name, :is_public, :status],
|
|
|
|
:include => {:repository => {:only => [:id, :url]}}
|
|
|
|
)
|
2007-04-01 23:43:59 +04:00
|
|
|
end
|
2011-05-25 08:39:33 +04:00
|
|
|
|
2009-02-11 01:03:25 +03:00
|
|
|
def create_project_repository
|
|
|
|
project = Project.find(params[:id])
|
|
|
|
if project.repository
|
|
|
|
render :nothing => true, :status => 409
|
|
|
|
else
|
|
|
|
logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}."
|
|
|
|
project.repository = Repository.factory(params[:vendor], params[:repository])
|
|
|
|
if project.repository && project.repository.save
|
2011-11-27 21:30:28 +04:00
|
|
|
render :xml => project.repository.to_xml(:only => [:id, :url]), :status => 201
|
2009-02-11 01:03:25 +03:00
|
|
|
else
|
|
|
|
render :nothing => true, :status => 422
|
|
|
|
end
|
|
|
|
end
|
2007-04-01 23:43:59 +04:00
|
|
|
end
|
2011-05-25 08:39:33 +04:00
|
|
|
|
2009-11-28 19:50:26 +03:00
|
|
|
def fetch_changesets
|
|
|
|
projects = []
|
|
|
|
if params[:id]
|
|
|
|
projects << Project.active.has_module(:repository).find(params[:id])
|
|
|
|
else
|
2012-01-15 22:19:19 +04:00
|
|
|
projects = Project.active.has_module(:repository).all
|
2009-11-28 19:50:26 +03:00
|
|
|
end
|
|
|
|
projects.each do |project|
|
2012-01-15 22:19:19 +04:00
|
|
|
project.repositories.each do |repository|
|
|
|
|
repository.fetch_changesets
|
2009-11-28 19:50:26 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
render :nothing => true, :status => 200
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
render :nothing => true, :status => 404
|
|
|
|
end
|
2007-04-01 23:43:59 +04:00
|
|
|
|
2009-02-11 01:03:25 +03:00
|
|
|
protected
|
2007-04-01 23:43:59 +04:00
|
|
|
|
2009-02-11 01:03:25 +03:00
|
|
|
def check_enabled
|
|
|
|
User.current = nil
|
2009-12-20 12:44:28 +03:00
|
|
|
unless Setting.sys_api_enabled? && params[:key].to_s == Setting.sys_api_key
|
|
|
|
render :text => 'Access denied. Repository management WS is disabled or key is invalid.', :status => 403
|
2009-02-11 01:03:25 +03:00
|
|
|
return false
|
|
|
|
end
|
2007-04-01 23:43:59 +04:00
|
|
|
end
|
|
|
|
end
|