##// END OF EJS Templates
Changes RedMine to Redmine in copyright notices....
Changes RedMine to Redmine in copyright notices. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9637 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r9442:b0414ec1fbab
r9454:e876d1bfc014
Show More
repositories_controller.rb
457 lines | 15.1 KiB | text/x-ruby | RubyLexer
/ app / controllers / repositories_controller.rb
Jean-Philippe Lang
SCM browser:...
r2738 # Redmine - project management software
Etienne Massip
Moved Date months/weeks calculations used in Graph to lib....
r8420 # Copyright (C) 2006-2012 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
Merged rails-3.2 branch....
r9346 require 'redmine/scm/adapters/abstract_adapter'
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
render :layout => !request.xhr?
end
def create
Toshi MARUYAMA
scm: git: fix creating and updating repository...
r9433 attrs = pickup_extra_info
@repository = Repository.factory(params[:repository_scm], attrs[:attrs])
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
@repository.attributes = attrs[:attrs]
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.put? && @repository.save
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
@users = @project.users
additional_user_ids = @committers.collect(&:last).collect(&:to_i) - @users.collect(&:id)
@users += User.find_all_by_id(additional_user_ids) unless additional_user_ids.empty?
@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
Eric Davis
Added branch and tag support to the git repository viewer. (#1406)...
r2735 @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
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
@changeset_pages = Paginator.new self, @changeset_count,
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697 per_page_option,
params['page']
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 @changesets = @repository.changesets.find(:all,
Toshi MARUYAMA
scm: space and tab cleanup of app/controllers/repositories_controller.rb....
r4697 :limit => @changeset_pages.items_per_page,
:offset => @changeset_pages.current.offset,
Toshi MARUYAMA
scm: controller: include parents in changesets (#5501)...
r7595 :include => [:user, :repository, :parents])
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
Fixed: view file at given revision with CVS....
r1539 @content = @repository.cat(@path, @rev)
Jean-Philippe Lang
Removes "xxx and return" calls (#4446)....
r3071 (show_error_not_found; return) unless @content
Toshi MARUYAMA
route: scm: split entry and raw actions...
r9442 if is_raw ||
Toshi MARUYAMA
scm: fix non ascii text files displaying (#6256)....
r5084 (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
! is_entry_text_data?(@content, @path)
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
send_data @content, send_opt
Jean-Philippe Lang
Fixed: empty lines when displaying repository files with Windows style eol....
r980 else
# Prevent empty lines when displaying a file with Windows style eol
Toshi MARUYAMA
scm: fix non ascii text files displaying (#6256)....
r5084 # TODO: UTF-16
# Is this needs? AttachmentsController reads file simply.
Jean-Philippe Lang
Fixed: empty lines when displaying repository files with Windows style eol....
r980 @content.gsub!("\r\n", "\n")
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
@issue = @changeset.find_referenced_issue_by_id(params[:issue_id])
if @issue && (!@issue.visible? || @changeset.issues.include?(@issue))
@issue = nil
end
if @issue
@changeset.issues << @issue
respond_to do |format|
format.js {
render :update do |page|
page.replace_html "related-issues", :partial => "related_issues"
page.visual_effect :highlight, "related-issue-#{@issue.id}"
end
}
end
else
respond_to do |format|
format.js {
render :update do |page|
page.alert(l(:label_issue) + ' ' + l('activerecord.errors.messages.invalid'))
end
}
end
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])
if @issue
@changeset.issues.delete(@issue)
end
respond_to do |format|
format.js {
render :update do |page|
page.remove "related-issue-#{@issue.id}"
end if @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)
@date_to = Date.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
Merged rails-3.2 branch....
r9346 commits_by_day = Changeset.count(
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497 :all, :group => :commit_date,
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 :conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
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
Merged rails-3.2 branch....
r9346 changes_by_day = Change.count(
:all, :group => :commit_date, :include => :changeset,
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
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
Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2....
r2430 12.times {|m| fields << month_name(((Date.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-Philippe Lang
Merged rails-3.2 branch....
r9346 commits_by_author = Changeset.count(:all, :group => :committer, :conditions => ["repository_id = ?", repository.id])
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}
Jean-Philippe Lang
added changes counts on the "commits per author" svn stat graph...
r382
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 changes_by_author = Change.count(:all, :group => :committer, :include => :changeset, :conditions => ["#{Changeset.table_name}.repository_id = ?", repository.id])
Jean-Philippe Lang
added changes counts on the "commits per author" svn stat graph...
r382 h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
Toshi MARUYAMA
scm: remove trailing white-spaces from repositories controller....
r5754
Jean-Philippe Lang
added simple svn statistics graphs, rendered using SVG::Graph...
r377 fields = commits_by_author.collect {|r| r.first}
Jean-Philippe Lang
added changes counts on the "commits per author" svn stat graph...
r382 commits_data = commits_by_author.collect {|r| r.last}
changes_data = commits_by_author.collect {|r| h[r.first] || 0}
Toshi MARUYAMA
scm: remove trailing white-spaces from repositories controller....
r5754
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
Jean-Philippe Lang
Commits per author graph: remove email adress in usernames (#1066)....
r1342 # Remove email adress in usernames
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
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 = SVG::Graph::BarHorizontal.new(
Jean-Philippe Lang
Wider SVG graphs in repository stats....
r1587 :height => 400,
: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
svn browser merged in trunk...
r103 end
Toshi MARUYAMA
scm: code clean up RepositoriesController....
r5497