summaryrefslogtreecommitdiffstats
path: root/app/models/repository.rb
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-05-05 01:30:24 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-05-05 01:30:24 +0000
commit86d9ea32dbd253607bfaa221e2924c95fcff8020 (patch)
tree4f0b94d53325461f7e4654bde7bc3c14be012bc4 /app/models/repository.rb
parent23360937395ae464986dff700029f28aa1109f90 (diff)
downloadredmine-86d9ea32dbd253607bfaa221e2924c95fcff8020.tar.gz
redmine-86d9ea32dbd253607bfaa221e2924c95fcff8020.zip
scm: code clean up repository model.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5647 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb22
1 files changed, 13 insertions, 9 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 3a0b6f911..987f9e657 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -134,7 +134,8 @@ class Repository < ActiveRecord::Base
# Finds and returns a revision with a number or the beginning of a hash
def find_changeset_by_name(name)
return nil if name.blank?
- changesets.find(:first, :conditions => (name.match(/^\d*$/) ? ["revision = ?", name.to_s] : ["revision LIKE ?", name + '%']))
+ changesets.find(:first, :conditions => (name.match(/^\d*$/) ?
+ ["revision = ?", name.to_s] : ["revision LIKE ?", name + '%']))
end
def latest_changeset
@@ -155,16 +156,17 @@ class Repository < ActiveRecord::Base
:limit => limit).collect(&:changeset)
end
end
-
+
def scan_changesets_for_issue_ids
self.changesets.each(&:scan_comment_for_issue_ids)
end
# Returns an array of committers usernames and associated user_id
def committers
- @committers ||= Changeset.connection.select_rows("SELECT DISTINCT committer, user_id FROM #{Changeset.table_name} WHERE repository_id = #{id}")
+ @committers ||= Changeset.connection.select_rows(
+ "SELECT DISTINCT committer, user_id FROM #{Changeset.table_name} WHERE repository_id = #{id}")
end
-
+
# Maps committers username to a user ids
def committer_ids=(h)
if h.is_a?(Hash)
@@ -172,17 +174,19 @@ class Repository < ActiveRecord::Base
new_user_id = h[committer]
if new_user_id && (new_user_id.to_i != user_id.to_i)
new_user_id = (new_user_id.to_i > 0 ? new_user_id.to_i : nil)
- Changeset.update_all("user_id = #{ new_user_id.nil? ? 'NULL' : new_user_id }", ["repository_id = ? AND committer = ?", id, committer])
+ Changeset.update_all(
+ "user_id = #{ new_user_id.nil? ? 'NULL' : new_user_id }",
+ ["repository_id = ? AND committer = ?", id, committer])
end
end
- @committers = nil
+ @committers = nil
@found_committer_users = nil
true
else
false
end
end
-
+
# Returns the Redmine User corresponding to the given +committer+
# It will return nil if the committer is not yet mapped and if no User
# with the same username or email was found
@@ -190,7 +194,7 @@ class Repository < ActiveRecord::Base
unless committer.blank?
@found_committer_users ||= {}
return @found_committer_users[committer] if @found_committer_users.has_key?(committer)
-
+
user = nil
c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user)
if c && c.user
@@ -288,7 +292,7 @@ class Repository < ActiveRecord::Base
root_url.strip!
true
end
-
+
def clear_changesets
cs, ch, ci = Changeset.table_name, Change.table_name, "#{table_name_prefix}changesets_issues#{table_name_suffix}"
connection.delete("DELETE FROM #{ch} WHERE #{ch}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")