##// END OF EJS Templates
Introduce virtual MenuNodes (#15880)....
Introduce virtual MenuNodes (#15880). They are characterized by having a blank url. they will only be rendered if the user is authorized to see at least one of its children. they render as links which do nothing when clicked. Patch by Jan Schulz-Hofen. git-svn-id: http://svn.redmine.org/redmine/trunk@15501 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r15027:3e776af8066e
r15119:53710d80fc88
Show More
repositories_controller.rb
452 lines | 14.4 KiB | text/x-ruby | RubyLexer
/ app / controllers / repositories_controller.rb
Jean-Philippe Lang
SCM browser:...
r2738 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
svn browser merged in trunk...
r103 #
# 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.
Toshi MARUYAMA
scm: remove trailing white-spaces from repositories controller....
r5754 #
Jean-Philippe Lang
svn browser merged in trunk...
r103 # 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.
Toshi MARUYAMA
scm: remove trailing white-spaces from repositories controller....
r5754 #
Jean-Philippe Lang
svn browser merged in trunk...
r103 # 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.
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 require 'SVG/Graph/Bar'
require 'SVG/Graph/BarHorizontal'
Jean-Philippe Lang
Added fragment caching for svn diffs....
r496 require 'digest/sha1'
Jean-Philippe Lang
Fixed uninitialized constant Redmine::Scm::Adapters::CommandFailed error when reloading in development mode....
r12043 require 'redmine/scm/adapters'
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377
Jean-Philippe Lang
Verify rev and rev_to params format in RepositoriesController. And turn revision arguments into integers in SubversionAdapter....
r1309 class ChangesetNotFound < Exception; end
class InvalidRevisionParam < Exception; end
Jean-Philippe Lang
* Added links to previous and next revisions on revision view (patch by Cyril Mougel slightly edited)...
r925
Jean-Philippe Lang
svn browser merged in trunk...
r103 class RepositoriesController < ApplicationController
Jean-Philippe Lang
Highlight the current item of the main menu....
r1062 menu_item :repository
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers]
Jean-Philippe Lang
Contextual quick search (#3263)....
r2829 default_search_scope :changesets
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 before_filter :find_project_by_project_id, :only => [:new, :create]
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
before_filter :find_project_repository, :except => [:new, :create, :edit, :update, :destroy, :committers]
Jean-Philippe Lang
Adds a "Manage related isses" permission to add/remove commits/issues relations manually from the changeset view (#2009)....
r8657 before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
Jean-Philippe Lang
Added project module concept....
r714 before_filter :authorize
Jean-Philippe Lang
Separation of RSS/API auth actions....
r6077 accept_rss_auth :revisions
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Jean-Philippe Lang
RepositoriesController cleanup with rescue_from....
r1541 rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 def new
Jean-Philippe Lang
Don't use a disabled SCM as a default repository SCM (#779)....
r8533 scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 @repository = Repository.factory(scm)
Jean-Philippe Lang
Adds support for multiple repositories per project (#779)....
r8530 @repository.is_default = @project.repository.nil?
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 @repository.project = @project
end
def create
Toshi MARUYAMA
scm: git: fix creating and updating repository...
r9433 attrs = pickup_extra_info
Jean-Philippe Lang
Safe attributes for repositories....
r9693 @repository = Repository.factory(params[:repository_scm])
@repository.safe_attributes = params[:repository]
Toshi MARUYAMA
scm: git: fix creating and updating repository...
r9433 if attrs[:attrs_extra].keys.any?
@repository.merge_extra_info(attrs[:attrs_extra])
end
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 @repository.project = @project
if request.post? && @repository.save
redirect_to settings_project_path(@project, :tab => 'repositories')
else
render :action => 'new'
Jean-Philippe Lang
Added project module concept....
r714 end
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 end
def edit
end
def update
Toshi MARUYAMA
scm: git: fix creating and updating repository...
r9433 attrs = pickup_extra_info
Jean-Philippe Lang
Safe attributes for repositories....
r9693 @repository.safe_attributes = attrs[:attrs]
Toshi MARUYAMA
scm: git: fix creating and updating repository...
r9433 if attrs[:attrs_extra].keys.any?
@repository.merge_extra_info(attrs[:attrs_extra])
end
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 @repository.project = @project
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 if @repository.save
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 redirect_to settings_project_path(@project, :tab => 'repositories')
else
render :action => 'edit'
Jean-Philippe Lang
Add "Repository" menu item after repository creation (#5328)....
r3566 end
Jean-Philippe Lang
Added project module concept....
r714 end
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Toshi MARUYAMA
scm: git: fix creating and updating repository...
r9433 def pickup_extra_info
p = {}
p_extra = {}
params[:repository].each do |k, v|
if k =~ /^extra_/
p_extra[k] = v
else
p[k] = v
end
end
{:attrs => p, :attrs_extra => p_extra}
end
private :pickup_extra_info
Jean-Philippe Lang
Maps repository users to Redmine users (#1383)....
r2004 def committers
@committers = @repository.committers
Jean-Philippe Lang
Fixed undefined method `compact!' error when additional_user_ids is empty (#19253)....
r13671 @users = @project.users.to_a
Jean-Philippe Lang
Maps repository users to Redmine users (#1383)....
r2004 additional_user_ids = @committers.collect(&:last).collect(&:to_i) - @users.collect(&:id)
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 @users += User.where(:id => additional_user_ids).to_a unless additional_user_ids.empty?
Jean-Philippe Lang
Maps repository users to Redmine users (#1383)....
r2004 @users.compact!
@users.sort!
Jean-Philippe Lang
Fixes repository user mapping submission when a repository username is blank (#2339, Conflicting types for parameter containers)....
r2135 if request.post? && params[:committers].is_a?(Hash)
# Build a hash with repository usernames as keys and corresponding user ids as values
@repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h}
Jean-Philippe Lang
Maps repository users to Redmine users (#1383)....
r2004 flash[:notice] = l(:notice_successful_update)
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 redirect_to settings_project_path(@project, :tab => 'repositories')
Jean-Philippe Lang
Maps repository users to Redmine users (#1383)....
r2004 end
end
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697
Jean-Philippe Lang
Added project module concept....
r714 def destroy
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 @repository.destroy if request.delete?
redirect_to settings_project_path(@project, :tab => 'repositories')
Jean-Philippe Lang
Added project module concept....
r714 end
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697
def show
Jean-Philippe Lang
Disable autofetching of repository changesets if projects are closed (#13945)....
r11608 @repository.fetch_changesets if @project.active? && Setting.autofetch_changesets? && @path.empty?
Eric Davis
Added branch and tag support to the git repository viewer. (#1406)...
r2735
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 @entries = @repository.entries(@path, @rev)
Toshi MARUYAMA
scm: recovery showing "root @ branch" in repository tree viewing....
r5019 @changeset = @repository.find_changeset_by_name(@rev)
Jean-Philippe Lang
Added a bit of AJAX on the SCM browser (tree view)....
r849 if request.xhr?
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
else
Jean-Philippe Lang
Removes "xxx and return" calls (#4446)....
r3071 (show_error_not_found; return) unless @entries
Jean-Philippe Lang
SCM:...
r2744 @changesets = @repository.latest_changesets(@path, @rev)
Jean-Philippe Lang
Display svn properties in the browser, svn >= 1.5.0 only (#1581)....
r1613 @properties = @repository.properties(@path, @rev)
Jean-Philippe Lang
Adds support for multiple repositories per project (#779)....
r8530 @repositories = @project.repositories
Eric Davis
Added branch and tag support to the git repository viewer. (#1406)...
r2735 render :action => 'show'
Jean-Philippe Lang
Added a bit of AJAX on the SCM browser (tree view)....
r849 end
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 end
Eric Davis
Added branch and tag support to the git repository viewer. (#1406)...
r2735
alias_method :browse, :show
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 def changes
Jean-Philippe Lang
Fixed: view file at given revision with CVS....
r1539 @entry = @repository.entry(@path, @rev)
Jean-Philippe Lang
Removes "xxx and return" calls (#4446)....
r3071 (show_error_not_found; return) unless @entry
Eric Davis
Added branch and tag support to the git repository viewer. (#1406)...
r2735 @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i)
Jean-Philippe Lang
Display svn properties in the browser, svn >= 1.5.0 only (#1581)....
r1613 @properties = @repository.properties(@path, @rev)
Toshi MARUYAMA
scm: use format_revision() for history, view and annotate (#3724)....
r4613 @changeset = @repository.find_changeset_by_name(@rev)
Jean-Philippe Lang
svn browser merged in trunk...
r103 end
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697
Jean-Philippe Lang
svn browser merged in trunk...
r103 def revisions
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 @changeset_count = @repository.changesets.count
Jean-Philippe Lang
Deprecation warnings (#12774)....
r10909 @changeset_pages = Paginator.new @changeset_count,
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697 per_page_option,
params['page']
Jean-Philippe Lang
Replaces find(:all) calls....
r10687 @changesets = @repository.changesets.
Jean-Philippe Lang
Use #per_page instead of #items_per_page....
r11195 limit(@changeset_pages.per_page).
Jean-Philippe Lang
Deprecation warnings (#12774)....
r10909 offset(@changeset_pages.offset).
Jean-Philippe Lang
Replaces find(:all) calls....
r10687 includes(:user, :repository, :parents).
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 to_a
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556
Jean-Philippe Lang
Merged 0.6 branch into trunk....
r663 respond_to do |format|
format.html { render :layout => false if request.xhr? }
format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") }
end
Jean-Philippe Lang
svn browser merged in trunk...
r103 end
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697
Toshi MARUYAMA
route: scm: split entry and raw actions...
r9442 def raw
entry_and_raw(true)
end
Jean-Philippe Lang
svn browser merged in trunk...
r103 def entry
Toshi MARUYAMA
route: scm: split entry and raw actions...
r9442 entry_and_raw(false)
end
def entry_and_raw(is_raw)
Jean-Philippe Lang
Fixed: view file at given revision with CVS....
r1539 @entry = @repository.entry(@path, @rev)
Jean-Philippe Lang
Removes "xxx and return" calls (#4446)....
r3071 (show_error_not_found; return) unless @entry
Jean-Philippe Lang
Fixed: Links to repository directories don't work (#1119)....
r1350 # If the entry is a dir, show the browser
Jean-Philippe Lang
Removes "xxx and return" calls (#4446)....
r3071 (show; return) if @entry.is_dir?
Jean-Philippe Lang
Add view for "no preview" repository files (#22482)....
r15015 if is_raw
Jean-Philippe Lang
Limit the size of repository files displayed inline too....
r2442 # Force the download
Toshi MARUYAMA
scm: set mime type in downloading file....
r5090 send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
send_type = Redmine::MimeType.of(@path)
send_opt[:type] = send_type.to_s if send_type
Jean-Philippe Lang
Don't force download of PDF (#22483)....
r15027 send_opt[:disposition] = disposition(@path)
Jean-Philippe Lang
Add view for "no preview" repository files (#22482)....
r15015 send_data @repository.cat(@path, @rev), send_opt
Jean-Philippe Lang
Fixed: empty lines when displaying repository files with Windows style eol....
r980 else
Jean-Philippe Lang
Add view for "no preview" repository files (#22482)....
r15015 if !@entry.size || @entry.size <= Setting.file_max_size_displayed.to_i.kilobyte
content = @repository.cat(@path, @rev)
(show_error_not_found; return) unless content
if content.size <= Setting.file_max_size_displayed.to_i.kilobyte &&
is_entry_text_data?(content, @path)
# TODO: UTF-16
# Prevent empty lines when displaying a file with Windows style eol
# Is this needed? AttachmentsController simply reads file.
@content = content.gsub("\r\n", "\n")
end
end
Toshi MARUYAMA
scm: use format_revision() for history, view and annotate (#3724)....
r4613 @changeset = @repository.find_changeset_by_name(@rev)
Toshi MARUYAMA
scm: fix non ascii text files displaying (#6256)....
r5084 end
end
Toshi MARUYAMA
route: scm: split entry and raw actions...
r9442 private :entry_and_raw
Toshi MARUYAMA
scm: fix non ascii text files displaying (#6256)....
r5084
def is_entry_text_data?(ent, path)
# UTF-16 contains "\x00".
Toshi MARUYAMA
scm: remove trailing white-spaces from repositories controller....
r5754 # It is very strict that file contains less than 30% of ascii symbols
Toshi MARUYAMA
scm: fix non ascii text files displaying (#6256)....
r5084 # in non Western Europe.
return true if Redmine::MimeType.is_type?('text', path)
# Ruby 1.8.6 has a bug of integer divisions.
# http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F
return false if ent.is_binary_data?
true
Jean-Philippe Lang
svn browser merged in trunk...
r103 end
Toshi MARUYAMA
scm: fix non ascii text files displaying (#6256)....
r5084 private :is_entry_text_data?
Toshi MARUYAMA
scm: use format_revision() for history, view and annotate (#3724)....
r4613
Jean-Philippe Lang
Added Annotate/Blame view for Subversion, CVS and Mercurial repositories....
r934 def annotate
Jean-Philippe Lang
Show view/annotate/download links on repositories/entries and repositories/annotate views (#2367)....
r2165 @entry = @repository.entry(@path, @rev)
Jean-Philippe Lang
Removes "xxx and return" calls (#4446)....
r3071 (show_error_not_found; return) unless @entry
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697
Jean-Philippe Lang
Added Annotate/Blame view for Subversion, CVS and Mercurial repositories....
r934 @annotate = @repository.scm.annotate(@path, @rev)
Toshi MARUYAMA
do not annotate text files which exceed the size limit for viewing (#9484)...
r7608 if @annotate.nil? || @annotate.empty?
(render_error l(:error_scm_annotate); return)
end
ann_buf_size = 0
@annotate.lines.each do |buf|
ann_buf_size += buf.size
end
if ann_buf_size > Setting.file_max_size_displayed.to_i.kilobyte
(render_error l(:error_scm_annotate_big_text_file); return)
end
Toshi MARUYAMA
scm: use format_revision() for history, view and annotate (#3724)....
r4613 @changeset = @repository.find_changeset_by_name(@rev)
Jean-Philippe Lang
Added Annotate/Blame view for Subversion, CVS and Mercurial repositories....
r934 end
Toshi MARUYAMA
scm: use format_revision() for history, view and annotate (#3724)....
r4613
Jean-Philippe Lang
svn browser merged in trunk...
r103 def revision
Jean-Philippe Lang
* Added links to previous and next revisions on revision view (patch by Cyril Mougel slightly edited)...
r925 respond_to do |format|
format.html
format.js {render :layout => false}
end
Jean-Philippe Lang
Adds a "Manage related isses" permission to add/remove commits/issues relations manually from the changeset view (#2009)....
r8657 end
# Adds a related issue to a changeset
# POST /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues
def add_related_issue
Jean-Philippe Lang
Accept issue id with leading sharp when adding a related issue....
r12020 issue_id = params[:issue_id].to_s.sub(/^#/,'')
@issue = @changeset.find_referenced_issue_by_id(issue_id)
Jean-Philippe Lang
Adds a "Manage related isses" permission to add/remove commits/issues relations manually from the changeset view (#2009)....
r8657 if @issue && (!@issue.visible? || @changeset.issues.include?(@issue))
@issue = nil
end
if @issue
@changeset.issues << @issue
end
end
# Removes a related issue from a changeset
# DELETE /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues/:issue_id
def remove_related_issue
@issue = Issue.visible.find_by_id(params[:issue_id])
Toshi MARUYAMA
remove trailing white-space from app/controllers/repositories_controller.rb...
r10521 if @issue
Jean-Philippe Lang
Adds a "Manage related isses" permission to add/remove commits/issues relations manually from the changeset view (#2009)....
r8657 @changeset.issues.delete(@issue)
end
Jean-Philippe Lang
svn browser merged in trunk...
r103 end
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697
Jean-Philippe Lang
svn browser merged in trunk...
r103 def diff
Jean-Philippe Lang
SCM browser: ability to download raw unified diffs....
r1500 if params[:format] == 'diff'
Jean-Philippe Lang
Move unified diff parser out of the scm abstract adapter so it can be reused for viewing attached diffs (#1403)....
r1499 @diff = @repository.diff(@path, @rev, @rev_to)
Jean-Philippe Lang
Removes "xxx and return" calls (#4446)....
r3071 (show_error_not_found; return) unless @diff
Jean-Philippe Lang
SCM browser: ability to download raw unified diffs....
r1500 filename = "changeset_r#{@rev}"
filename << "_r#{@rev_to}" if @rev_to
send_data @diff.join, :filename => "#{filename}.diff",
:type => 'text/x-patch',
:disposition => 'attachment'
else
@diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
@diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
Toshi MARUYAMA
scm: remove trailing white-spaces from repositories controller....
r5754
Jean-Philippe Lang
SCM browser: ability to download raw unified diffs....
r1500 # Save diff type as user preference
if User.current.logged? && @diff_type != User.current.pref[:diff_type]
User.current.pref[:diff_type] = @diff_type
User.current.preference.save
end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/repositories_controller.rb....
r6771 @cache_key = "repositories/diff/#{@repository.id}/" +
Jean-Baptiste Barth
Do not cache I18n strings when truncating a long diff (#5089)....
r5953 Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}")
Jean-Philippe Lang
SCM browser: ability to download raw unified diffs....
r1500 unless read_fragment(@cache_key)
@diff = @repository.diff(@path, @rev, @rev_to)
show_error_not_found unless @diff
end
Toshi MARUYAMA
Changing revision label and identifier at SCM adapter level (#3724, #6092)...
r4493
@changeset = @repository.find_changeset_by_name(@rev)
@changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil
Toshi MARUYAMA
scm: changing two revision diff text at SCM adapter level (#3724)....
r4578 @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to)
Jean-Philippe Lang
Added fragment caching for svn diffs....
r496 end
Jean-Philippe Lang
svn browser merged in trunk...
r103 end
Toshi MARUYAMA
scm: changing two revision diff text at SCM adapter level (#3724)....
r4578
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697 def stats
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 end
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 def graph
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697 data = nil
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 case params[:graph]
when "commits_per_month"
data = graph_commits_per_month(@repository)
when "commits_per_author"
data = graph_commits_per_author(@repository)
end
if data
headers["Content-Type"] = "image/svg+xml"
send_data(data, :type => "image/svg+xml", :disposition => "inline")
else
render_404
end
end
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Jean-Philippe Lang
Restore rev param validation that was removed in r2840....
r4428 private
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 def find_repository
@repository = Repository.find(params[:id])
@project = @repository.project
rescue ActiveRecord::RecordNotFound
render_404
end
Jean-Philippe Lang
Fixes valid revision regexp....
r4435 REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i
Jean-Philippe Lang
Restore rev param validation that was removed in r2840....
r4428
Jean-Philippe Lang
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779)....
r8528 def find_project_repository
Jean-Philippe Lang
Added project module concept....
r714 @project = Project.find(params[:id])
Jean-Philippe Lang
Adds support for multiple repositories per project (#779)....
r8530 if params[:repository_id].present?
@repository = @project.repositories.find_by_identifier_param(params[:repository_id])
else
@repository = @project.repository
end
Jean-Philippe Lang
Removes "xxx and return" calls (#4446)....
r3071 (render_404; return false) unless @repository
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 @path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
Toshi MARUYAMA
Rails3: controller: repositories: use to_s for revision parameter...
r7502 @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip
Jean-Philippe Lang
Verify rev and rev_to params format in RepositoriesController. And turn revision arguments into integers in SubversionAdapter....
r1309 @rev_to = params[:rev_to]
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Toshi MARUYAMA
scm: fix diff revision param validation....
r4740 unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE)
Jean-Philippe Lang
Restore rev param validation that was removed in r2840....
r4428 if @repository.branches.blank?
raise InvalidRevisionParam
end
end
Jean-Philippe Lang
ActiveRecord::RecordNotFound exceptions handled more gracefully...
r130 rescue ActiveRecord::RecordNotFound
render_404
Jean-Philippe Lang
Verify rev and rev_to params format in RepositoriesController. And turn revision arguments into integers in SubversionAdapter....
r1309 rescue InvalidRevisionParam
show_error_not_found
Jean-Philippe Lang
svn browser merged in trunk...
r103 end
Jean-Philippe Lang
Adds a "Manage related isses" permission to add/remove commits/issues relations manually from the changeset view (#2009)....
r8657 def find_changeset
if @rev.present?
@changeset = @repository.find_changeset_by_name(@rev)
end
show_error_not_found unless @changeset
end
Jean-Philippe Lang
Show explicit error message when the scm command failed (eg. when svn binary is not available)....
r1080 def show_error_not_found
Jean-Philippe Lang
Respond with 404 instead of 500 when revision/entry is not found in the repository (#7307)....
r4590 render_error :message => l(:error_scm_not_found), :status => 404
Jean-Philippe Lang
Show explicit error message when the scm command failed (eg. when svn binary is not available)....
r1080 end
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Jean-Philippe Lang
RepositoriesController cleanup with rescue_from....
r1541 # Handler for Redmine::Scm::Adapters::CommandFailed exception
def show_error_command_failed(exception)
render_error l(:error_scm_command_failed, exception.message)
Jean-Philippe Lang
svn browser merged in trunk...
r103 end
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 def graph_commits_per_month(repository)
Jean-Philippe Lang
Replace Date.today with User.current.today (#22320)....
r14997 @date_to = User.current.today
Jean-Philippe Lang
Fixed: nil error on 'commits per month' graph....
r639 @date_from = @date_to << 11
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
Jean-Philippe Lang
Cleanup of finders with :conditions option....
r11733 commits_by_day = Changeset.
where("repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to).
group(:commit_date).
count
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 commits_by_month = [0] * 12
Jean-Philippe Lang
Fixed error on commits per month graph (#10806)....
r9427 commits_by_day.each {|c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377
Jean-Philippe Lang
Cleanup of finders with :conditions option....
r11733 changes_by_day = Change.
joins(:changeset).
where("#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to).
group(:commit_date).
count
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 changes_by_month = [0] * 12
Jean-Philippe Lang
Fixed error on commits per month graph (#10806)....
r9427 changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 fields = []
Jean-Philippe Lang
Replace Date.today with User.current.today (#22320)....
r14997 today = User.current.today
12.times {|m| fields << month_name(((today.month - 1 - m) % 12) + 1)}
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 graph = SVG::Graph::Bar.new(
:height => 300,
Jean-Philippe Lang
Wider SVG graphs in repository stats....
r1587 :width => 800,
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 :fields => fields.reverse,
:stack => :side,
:scale_integers => true,
:step_x_labels => 2,
:show_data_values => false,
:graph_title => l(:label_commits_per_month),
:show_graph_title => true
)
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 graph.add_data(
:data => commits_by_month[0..11].reverse,
:title => l(:label_revision_plural)
)
graph.add_data(
:data => changes_by_month[0..11].reverse,
:title => l(:label_change_plural)
)
Toshi MARUYAMA
scm: remove trailing white-spaces from repositories controller....
r5754
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 graph.burn
end
def graph_commits_per_author(repository)
Jean-Baptiste Barth
Move some RepositoriesController logic to Repository#stats_by_author (#13487)....
r12997 #data
stats = repository.stats_by_author
fields, commits_data, changes_data = [], [], []
stats.each do |name, hsh|
fields << name
commits_data << hsh[:commits_count]
changes_data << hsh[:changes_count]
end
Toshi MARUYAMA
scm: remove trailing white-spaces from repositories controller....
r5754
Jean-Baptiste Barth
Move some RepositoriesController logic to Repository#stats_by_author (#13487)....
r12997 #expand to 10 values if needed
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 fields = fields + [""]*(10 - fields.length) if fields.length<10
Jean-Philippe Lang
added changes counts on the "commits per author" svn stat graph...
r382 commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10
Toshi MARUYAMA
scm: remove trailing white-spaces from repositories controller....
r5754
Toshi MARUYAMA
fix typo at app/controllers/repositories_controller.rb...
r12817 # Remove email address in usernames
Jean-Philippe Lang
Commits per author graph: remove email adress in usernames (#1066)....
r1342 fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
Toshi MARUYAMA
scm: remove trailing white-spaces from repositories controller....
r5754
Jean-Baptiste Barth
Move some RepositoriesController logic to Repository#stats_by_author (#13487)....
r12997 #prepare graph
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 graph = SVG::Graph::BarHorizontal.new(
Toshi MARUYAMA
increase base height of author lines on 'Commits per author' graph (#14068, #1983)...
r11617 :height => 30 * commits_data.length,
Jean-Philippe Lang
Wider SVG graphs in repository stats....
r1587 :width => 800,
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 :fields => fields,
:stack => :side,
:scale_integers => true,
:show_data_values => false,
:rotate_y_labels => false,
:graph_title => l(:label_commits_per_author),
:show_graph_title => true
)
graph.add_data(
Jean-Philippe Lang
added changes counts on the "commits per author" svn stat graph...
r382 :data => commits_data,
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 :title => l(:label_revision_plural)
)
Jean-Philippe Lang
added changes counts on the "commits per author" svn stat graph...
r382 graph.add_data(
:data => changes_data,
:title => l(:label_change_plural)
)
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 graph.burn
end
Jean-Philippe Lang
Don't force download of PDF (#22483)....
r15027
def disposition(path)
if Redmine::MimeType.is_type?('image', @path) || Redmine::MimeType.of(@path) == "application/pdf"
'inline'
else
'attachment'
end
end
Jean-Philippe Lang
svn browser merged in trunk...
r103 end