Mercurial > hg > soundsoftware-site
comparison app/models/repository.rb @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | 433d4f72a19b |
children | 4f746d8966dd |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
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(show entry raw changes annotate diff show stats graph) |
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 => /^(?!\d+$)[a-z0-9\-_]*$/, :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 |
49 safe_attributes 'identifier', | 49 safe_attributes 'identifier', |
50 'login', | 50 'login', |
232 | 232 |
233 # Finds and returns a revision with a number or the beginning of a hash | 233 # Finds and returns a revision with a number or the beginning of a hash |
234 def find_changeset_by_name(name) | 234 def find_changeset_by_name(name) |
235 return nil if name.blank? | 235 return nil if name.blank? |
236 s = name.to_s | 236 s = name.to_s |
237 changesets.find(:first, :conditions => (s.match(/^\d*$/) ? | 237 if s.match(/^\d*$/) |
238 ["revision = ?", s] : ["revision LIKE ?", s + '%'])) | 238 changesets.where("revision = ?", s).first |
239 else | |
240 changesets.where("revision LIKE ?", s + '%').first | |
241 end | |
239 end | 242 end |
240 | 243 |
241 def latest_changeset | 244 def latest_changeset |
242 @latest_changeset ||= changesets.find(:first) | 245 @latest_changeset ||= changesets.first |
243 end | 246 end |
244 | 247 |
245 # Returns the latest changesets for +path+ | 248 # Returns the latest changesets for +path+ |
246 # Default behaviour is to search in cached changesets | 249 # Default behaviour is to search in cached changesets |
247 def latest_changesets(path, rev, limit=10) | 250 def latest_changesets(path, rev, limit=10) |
299 unless committer.blank? | 302 unless committer.blank? |
300 @found_committer_users ||= {} | 303 @found_committer_users ||= {} |
301 return @found_committer_users[committer] if @found_committer_users.has_key?(committer) | 304 return @found_committer_users[committer] if @found_committer_users.has_key?(committer) |
302 | 305 |
303 user = nil | 306 user = nil |
304 c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user) | 307 c = changesets.where(:committer => committer).includes(:user).first |
305 if c && c.user | 308 if c && c.user |
306 user = c.user | 309 user = c.user |
307 elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/ | 310 elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/ |
308 username, email = $1.strip, $3 | 311 username, email = $1.strip, $3 |
309 u = User.find_by_login(username) | 312 u = User.find_by_login(username) |
335 end | 338 end |
336 end | 339 end |
337 | 340 |
338 # scan changeset comments to find related and fixed issues for all repositories | 341 # scan changeset comments to find related and fixed issues for all repositories |
339 def self.scan_changesets_for_issue_ids | 342 def self.scan_changesets_for_issue_ids |
340 find(:all).each(&:scan_changesets_for_issue_ids) | 343 all.each(&:scan_changesets_for_issue_ids) |
341 end | 344 end |
342 | 345 |
343 def self.scm_name | 346 def self.scm_name |
344 'Abstract' | 347 'Abstract' |
345 end | 348 end |