comparison app/models/repository.rb @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents e248c7af89ec
children a1bdbf8a87d5
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
38 38
39 validates_length_of :password, :maximum => 255, :allow_nil => true 39 validates_length_of :password, :maximum => 255, :allow_nil => true
40 validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true 40 validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
41 validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? } 41 validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
42 validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true 42 validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
43 validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph) 43 validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision)
44 # donwcase letters, digits, dashes, underscores but not digits only 44 # donwcase letters, digits, dashes, underscores but not digits only
45 validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true 45 validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true
46 # Checks if the SCM is enabled when creating a repository 46 # Checks if the SCM is enabled when creating a repository
47 validate :repo_create_validation, :on => :create 47 validate :repo_create_validation, :on => :create
48 48
192 192
193 def entry(path=nil, identifier=nil) 193 def entry(path=nil, identifier=nil)
194 scm.entry(path, identifier) 194 scm.entry(path, identifier)
195 end 195 end
196 196
197 def scm_entries(path=nil, identifier=nil)
198 scm.entries(path, identifier)
199 end
200 protected :scm_entries
201
197 def entries(path=nil, identifier=nil) 202 def entries(path=nil, identifier=nil)
198 entries = scm.entries(path, identifier) 203 entries = scm_entries(path, identifier)
199 load_entries_changesets(entries) 204 load_entries_changesets(entries)
200 entries 205 entries
201 end 206 end
202 207
203 def branches 208 def branches
285 if h.is_a?(Hash) 290 if h.is_a?(Hash)
286 committers.each do |committer, user_id| 291 committers.each do |committer, user_id|
287 new_user_id = h[committer] 292 new_user_id = h[committer]
288 if new_user_id && (new_user_id.to_i != user_id.to_i) 293 if new_user_id && (new_user_id.to_i != user_id.to_i)
289 new_user_id = (new_user_id.to_i > 0 ? new_user_id.to_i : nil) 294 new_user_id = (new_user_id.to_i > 0 ? new_user_id.to_i : nil)
290 Changeset.update_all( 295 Changeset.where(["repository_id = ? AND committer = ?", id, committer]).
291 "user_id = #{ new_user_id.nil? ? 'NULL' : new_user_id }", 296 update_all("user_id = #{new_user_id.nil? ? 'NULL' : new_user_id}")
292 ["repository_id = ? AND committer = ?", id, committer])
293 end 297 end
294 end 298 end
295 @committers = nil 299 @committers = nil
296 @found_committer_users = nil 300 @found_committer_users = nil
297 true 301 true
406 def check_default 410 def check_default
407 if !is_default? && set_as_default? 411 if !is_default? && set_as_default?
408 self.is_default = true 412 self.is_default = true
409 end 413 end
410 if is_default? && is_default_changed? 414 if is_default? && is_default_changed?
411 Repository.update_all(["is_default = ?", false], ["project_id = ?", project_id]) 415 Repository.where(["project_id = ?", project_id]).update_all(["is_default = ?", false])
412 end 416 end
413 end 417 end
414 418
415 def load_entries_changesets(entries) 419 def load_entries_changesets(entries)
416 if entries 420 if entries