@@ -26,14 +26,14 class RepositoriesController < ApplicationController | |||
|
26 | 26 | menu_item :repository |
|
27 | 27 | menu_item :settings, :only => :edit |
|
28 | 28 | default_search_scope :changesets |
|
29 | ||
|
29 | ||
|
30 | 30 | before_filter :find_repository, :except => :edit |
|
31 | 31 | before_filter :find_project, :only => :edit |
|
32 | 32 | before_filter :authorize |
|
33 | 33 | accept_key_auth :revisions |
|
34 | ||
|
34 | ||
|
35 | 35 | rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed |
|
36 | ||
|
36 | ||
|
37 | 37 | def edit |
|
38 | 38 | @repository = @project.repository |
|
39 | 39 | if !@repository |
@@ -52,7 +52,7 class RepositoriesController < ApplicationController | |||
|
52 | 52 | end |
|
53 | 53 | end |
|
54 | 54 | end |
|
55 | ||
|
55 | ||
|
56 | 56 | def committers |
|
57 | 57 | @committers = @repository.committers |
|
58 | 58 | @users = @project.users |
@@ -192,8 +192,7 class RepositoriesController < ApplicationController | |||
|
192 | 192 | User.current.pref[:diff_type] = @diff_type |
|
193 | 193 | User.current.preference.save |
|
194 | 194 | end |
|
195 | ||
|
196 | @cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}") | |
|
195 | @cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}") | |
|
197 | 196 | unless read_fragment(@cache_key) |
|
198 | 197 | @diff = @repository.diff(@path, @rev, @rev_to) |
|
199 | 198 | show_error_not_found unless @diff |
@@ -223,7 +222,7 class RepositoriesController < ApplicationController | |||
|
223 | 222 | render_404 |
|
224 | 223 | end |
|
225 | 224 | end |
|
226 | ||
|
225 | ||
|
227 | 226 | private |
|
228 | 227 | |
|
229 | 228 | REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i |
@@ -236,7 +235,7 class RepositoriesController < ApplicationController | |||
|
236 | 235 | @path ||= '' |
|
237 | 236 | @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip |
|
238 | 237 | @rev_to = params[:rev_to] |
|
239 | ||
|
238 | ||
|
240 | 239 | unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE) |
|
241 | 240 | if @repository.branches.blank? |
|
242 | 241 | raise InvalidRevisionParam |
@@ -251,27 +250,31 class RepositoriesController < ApplicationController | |||
|
251 | 250 | def show_error_not_found |
|
252 | 251 | render_error :message => l(:error_scm_not_found), :status => 404 |
|
253 | 252 | end |
|
254 | ||
|
253 | ||
|
255 | 254 | # Handler for Redmine::Scm::Adapters::CommandFailed exception |
|
256 | 255 | def show_error_command_failed(exception) |
|
257 | 256 | render_error l(:error_scm_command_failed, exception.message) |
|
258 | 257 | end |
|
259 | ||
|
258 | ||
|
260 | 259 | def graph_commits_per_month(repository) |
|
261 | 260 | @date_to = Date.today |
|
262 | 261 | @date_from = @date_to << 11 |
|
263 | 262 | @date_from = Date.civil(@date_from.year, @date_from.month, 1) |
|
264 | commits_by_day = repository.changesets.count(:all, :group => :commit_date, :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to]) | |
|
263 | commits_by_day = repository.changesets.count( | |
|
264 | :all, :group => :commit_date, | |
|
265 | :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to]) | |
|
265 | 266 | commits_by_month = [0] * 12 |
|
266 | 267 | commits_by_day.each {|c| commits_by_month[c.first.to_date.months_ago] += c.last } |
|
267 | 268 | |
|
268 | changes_by_day = repository.changes.count(:all, :group => :commit_date, :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to]) | |
|
269 | changes_by_day = repository.changes.count( | |
|
270 | :all, :group => :commit_date, | |
|
271 | :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to]) | |
|
269 | 272 | changes_by_month = [0] * 12 |
|
270 | 273 | changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last } |
|
271 | ||
|
274 | ||
|
272 | 275 | fields = [] |
|
273 | 276 | 12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)} |
|
274 | ||
|
277 | ||
|
275 | 278 | graph = SVG::Graph::Bar.new( |
|
276 | 279 | :height => 300, |
|
277 | 280 | :width => 800, |
@@ -283,7 +286,7 class RepositoriesController < ApplicationController | |||
|
283 | 286 | :graph_title => l(:label_commits_per_month), |
|
284 | 287 | :show_graph_title => true |
|
285 | 288 | ) |
|
286 | ||
|
289 | ||
|
287 | 290 | graph.add_data( |
|
288 | 291 | :data => commits_by_month[0..11].reverse, |
|
289 | 292 | :title => l(:label_revision_plural) |
@@ -326,22 +329,18 class RepositoriesController < ApplicationController | |||
|
326 | 329 | :graph_title => l(:label_commits_per_author), |
|
327 | 330 | :show_graph_title => true |
|
328 | 331 | ) |
|
329 | ||
|
330 | 332 | graph.add_data( |
|
331 | 333 | :data => commits_data, |
|
332 | 334 | :title => l(:label_revision_plural) |
|
333 | 335 | ) |
|
334 | ||
|
335 | 336 | graph.add_data( |
|
336 | 337 | :data => changes_data, |
|
337 | 338 | :title => l(:label_change_plural) |
|
338 | 339 | ) |
|
339 | ||
|
340 | 340 | graph.burn |
|
341 | 341 | end |
|
342 | ||
|
343 | 342 | end |
|
344 | ||
|
343 | ||
|
345 | 344 | class Date |
|
346 | 345 | def months_ago(date = Date.today) |
|
347 | 346 | (date.year - self.year)*12 + (date.month - self.month) |
General Comments 0
You need to be logged in to leave comments.
Login now