Mercurial > hg > soundsoftware-site
diff app/models/repository.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | bb32da3bea34 622f24f53b42 |
children |
line wrap: on
line diff
--- a/app/models/repository.rb Fri Jun 14 09:07:32 2013 +0100 +++ b/app/models/repository.rb Fri Jun 14 09:28:30 2013 +0100 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2012 Jean-Philippe Lang +# Copyright (C) 2006-2013 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -42,7 +42,7 @@ validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph) # donwcase letters, digits, dashes, underscores but not digits only - validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-_]*$/, :allow_blank => true + validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true # Checks if the SCM is enabled when creating a repository validate :repo_create_validation, :on => :create @@ -234,12 +234,15 @@ def find_changeset_by_name(name) return nil if name.blank? s = name.to_s - changesets.find(:first, :conditions => (s.match(/^\d*$/) ? - ["revision = ?", s] : ["revision LIKE ?", s + '%'])) + if s.match(/^\d*$/) + changesets.where("revision = ?", s).first + else + changesets.where("revision LIKE ?", s + '%').first + end end def latest_changeset - @latest_changeset ||= changesets.find(:first) + @latest_changeset ||= changesets.first end # Returns the latest changesets for +path+ @@ -301,7 +304,7 @@ return @found_committer_users[committer] if @found_committer_users.has_key?(committer) user = nil - c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user) + c = changesets.where(:committer => committer).includes(:user).first if c && c.user user = c.user elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/ @@ -337,7 +340,7 @@ # scan changeset comments to find related and fixed issues for all repositories def self.scan_changesets_for_issue_ids - find(:all).each(&:scan_changesets_for_issue_ids) + all.each(&:scan_changesets_for_issue_ids) end def self.scm_name