@@ -19,8 +19,8 require 'SVG/Graph/Bar' | |||||
19 | require 'SVG/Graph/BarHorizontal' |
|
19 | require 'SVG/Graph/BarHorizontal' | |
20 | require 'digest/sha1' |
|
20 | require 'digest/sha1' | |
21 |
|
21 | |||
22 | class ChangesetNotFound < Exception |
|
22 | class ChangesetNotFound < Exception; end | |
23 | end |
|
23 | class InvalidRevisionParam < Exception; end | |
24 |
|
24 | |||
25 | class RepositoriesController < ApplicationController |
|
25 | class RepositoriesController < ApplicationController | |
26 | layout 'base' |
|
26 | layout 'base' | |
@@ -135,7 +135,6 class RepositoriesController < ApplicationController | |||||
135 | end |
|
135 | end | |
136 |
|
136 | |||
137 | def diff |
|
137 | def diff | |
138 | @rev_to = params[:rev_to] |
|
|||
139 | @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline' |
|
138 | @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline' | |
140 | @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type) |
|
139 | @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type) | |
141 |
|
140 | |||
@@ -180,6 +179,8 private | |||||
180 | render_404 |
|
179 | render_404 | |
181 | end |
|
180 | end | |
182 |
|
181 | |||
|
182 | REV_PARAM_RE = %r{^[a-f0-9]*$} | |||
|
183 | ||||
183 | def find_repository |
|
184 | def find_repository | |
184 | @project = Project.find(params[:id]) |
|
185 | @project = Project.find(params[:id]) | |
185 | @repository = @project.repository |
|
186 | @repository = @project.repository | |
@@ -187,8 +188,12 private | |||||
187 | @path = params[:path].join('/') unless params[:path].nil? |
|
188 | @path = params[:path].join('/') unless params[:path].nil? | |
188 | @path ||= '' |
|
189 | @path ||= '' | |
189 | @rev = params[:rev] |
|
190 | @rev = params[:rev] | |
|
191 | @rev_to = params[:rev_to] | |||
|
192 | raise InvalidRevisionParam unless @rev.to_s.match(REV_PARAM_RE) && @rev.to_s.match(REV_PARAM_RE) | |||
190 | rescue ActiveRecord::RecordNotFound |
|
193 | rescue ActiveRecord::RecordNotFound | |
191 | render_404 |
|
194 | render_404 | |
|
195 | rescue InvalidRevisionParam | |||
|
196 | show_error_not_found | |||
192 | end |
|
197 | end | |
193 |
|
198 | |||
194 | def show_error_not_found |
|
199 | def show_error_not_found |
@@ -62,7 +62,7 module Redmine | |||||
62 | # or nil if the given path doesn't exist in the repository |
|
62 | # or nil if the given path doesn't exist in the repository | |
63 | def entries(path=nil, identifier=nil) |
|
63 | def entries(path=nil, identifier=nil) | |
64 | path ||= '' |
|
64 | path ||= '' | |
65 |
identifier = |
|
65 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" | |
66 | entries = Entries.new |
|
66 | entries = Entries.new | |
67 | cmd = "#{SVN_BIN} list --xml #{target(path)}@#{identifier}" |
|
67 | cmd = "#{SVN_BIN} list --xml #{target(path)}@#{identifier}" | |
68 | cmd << credentials_string |
|
68 | cmd << credentials_string | |
@@ -94,8 +94,8 module Redmine | |||||
94 |
|
94 | |||
95 | def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) |
|
95 | def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) | |
96 | path ||= '' |
|
96 | path ||= '' | |
97 |
identifier_from = |
|
97 | identifier_from = (identifier_from and identifier_from.to_i > 0) ? identifier_from.to_i : "HEAD" | |
98 |
identifier_to = |
|
98 | identifier_to = (identifier_to and identifier_to.to_i > 0) ? identifier_to.to_i : 1 | |
99 | revisions = Revisions.new |
|
99 | revisions = Revisions.new | |
100 | cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}" |
|
100 | cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}" | |
101 | cmd << credentials_string |
|
101 | cmd << credentials_string | |
@@ -131,11 +131,9 module Redmine | |||||
131 |
|
131 | |||
132 | def diff(path, identifier_from, identifier_to=nil, type="inline") |
|
132 | def diff(path, identifier_from, identifier_to=nil, type="inline") | |
133 | path ||= '' |
|
133 | path ||= '' | |
134 |
if identifier_ |
|
134 | identifier_from = (identifier_from and identifier_from.to_i > 0) ? identifier_from.to_i : '' | |
135 | identifier_to = identifier_to.to_i |
|
135 | identifier_to = (identifier_to and identifier_to.to_i > 0) ? identifier_to.to_i : (identifier_from.to_i - 1) | |
136 |
|
|
136 | ||
137 | identifier_to = identifier_from.to_i - 1 |
|
|||
138 | end |
|
|||
139 | cmd = "#{SVN_BIN} diff -r " |
|
137 | cmd = "#{SVN_BIN} diff -r " | |
140 | cmd << "#{identifier_to}:" |
|
138 | cmd << "#{identifier_to}:" | |
141 | cmd << "#{identifier_from}" |
|
139 | cmd << "#{identifier_from}" |
General Comments 0
You need to be logged in to leave comments.
Login now