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