2011-05-05 11:30:22 +04:00
|
|
|
# Redmine - project management software
|
2014-01-30 02:45:39 +04:00
|
|
|
# Copyright (C) 2006-2014 Jean-Philippe Lang
|
2006-12-24 16:38:45 +03:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-05-05 11:30:22 +04:00
|
|
|
#
|
2006-12-24 16:38:45 +03:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2011-05-05 11:30:22 +04:00
|
|
|
#
|
2006-12-24 16:38:45 +03:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
2011-05-25 15:33:36 +04:00
|
|
|
class ScmFetchError < Exception; end
|
|
|
|
|
2006-12-24 16:38:45 +03:00
|
|
|
class Repository < ActiveRecord::Base
|
2011-02-26 16:09:25 +03:00
|
|
|
include Redmine::Ciphering
|
2012-06-19 23:47:54 +04:00
|
|
|
include Redmine::SafeAttributes
|
2012-11-28 14:46:10 +04:00
|
|
|
|
2012-07-26 21:41:47 +04:00
|
|
|
# Maximum length for repository identifiers
|
|
|
|
IDENTIFIER_MAX_LENGTH = 255
|
2011-05-05 11:30:22 +04:00
|
|
|
|
2006-12-24 16:38:45 +03:00
|
|
|
belongs_to :project
|
2008-07-14 01:55:13 +04:00
|
|
|
has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
|
2012-06-03 15:46:58 +04:00
|
|
|
has_many :filechanges, :class_name => 'Change', :through => :changesets
|
2011-05-05 11:30:22 +04:00
|
|
|
|
2011-05-12 21:29:18 +04:00
|
|
|
serialize :extra_info
|
|
|
|
|
2012-01-15 22:19:19 +04:00
|
|
|
before_save :check_default
|
|
|
|
|
2008-07-14 01:55:13 +04:00
|
|
|
# Raw SQL to delete changesets and changes in the database
|
|
|
|
# has_many :changesets, :dependent => :destroy is too slow for big repositories
|
|
|
|
before_destroy :clear_changesets
|
2011-05-05 11:30:22 +04:00
|
|
|
|
2011-02-26 16:09:25 +03:00
|
|
|
validates_length_of :password, :maximum => 255, :allow_nil => true
|
2012-07-26 21:41:47 +04:00
|
|
|
validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
|
2012-01-15 22:19:19 +04:00
|
|
|
validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
|
|
|
|
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)
|
2012-06-19 23:12:17 +04:00
|
|
|
# donwcase letters, digits, dashes, underscores but not digits only
|
2012-12-08 14:59:31 +04:00
|
|
|
validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true
|
2008-06-08 18:59:26 +04:00
|
|
|
# Checks if the SCM is enabled when creating a repository
|
2011-08-29 09:48:11 +04:00
|
|
|
validate :repo_create_validation, :on => :create
|
|
|
|
|
2012-06-19 23:47:54 +04:00
|
|
|
safe_attributes 'identifier',
|
|
|
|
'login',
|
|
|
|
'password',
|
|
|
|
'path_encoding',
|
|
|
|
'log_encoding',
|
|
|
|
'is_default'
|
|
|
|
|
2012-06-20 22:45:51 +04:00
|
|
|
safe_attributes 'url',
|
|
|
|
:if => lambda {|repository, user| repository.new_record?}
|
|
|
|
|
2011-08-29 09:48:11 +04:00
|
|
|
def repo_create_validation
|
|
|
|
unless Setting.enabled_scm.include?(self.class.name.demodulize)
|
|
|
|
errors.add(:type, :invalid)
|
|
|
|
end
|
|
|
|
end
|
2011-02-24 08:58:59 +03:00
|
|
|
|
2011-12-18 17:20:19 +04:00
|
|
|
def self.human_attribute_name(attribute_key_name, *args)
|
2012-02-24 18:57:26 +04:00
|
|
|
attr_name = attribute_key_name.to_s
|
2011-04-23 07:34:43 +04:00
|
|
|
if attr_name == "log_encoding"
|
|
|
|
attr_name = "commit_logs_encoding"
|
|
|
|
end
|
2011-12-18 17:20:19 +04:00
|
|
|
super(attr_name, *args)
|
2011-04-23 07:34:43 +04:00
|
|
|
end
|
|
|
|
|
2008-03-14 21:59:10 +03:00
|
|
|
# Removes leading and trailing whitespace
|
|
|
|
def url=(arg)
|
|
|
|
write_attribute(:url, arg ? arg.to_s.strip : nil)
|
|
|
|
end
|
2011-02-24 08:58:59 +03:00
|
|
|
|
2008-03-14 21:59:10 +03:00
|
|
|
# Removes leading and trailing whitespace
|
|
|
|
def root_url=(arg)
|
|
|
|
write_attribute(:root_url, arg ? arg.to_s.strip : nil)
|
|
|
|
end
|
2011-05-05 11:30:22 +04:00
|
|
|
|
2011-02-26 16:09:25 +03:00
|
|
|
def password
|
|
|
|
read_ciphered_attribute(:password)
|
|
|
|
end
|
2011-05-05 11:30:22 +04:00
|
|
|
|
2011-02-26 16:09:25 +03:00
|
|
|
def password=(arg)
|
|
|
|
write_ciphered_attribute(:password, arg)
|
|
|
|
end
|
2008-03-14 21:59:10 +03:00
|
|
|
|
2011-02-14 11:45:34 +03:00
|
|
|
def scm_adapter
|
|
|
|
self.class.scm_adapter_class
|
|
|
|
end
|
|
|
|
|
2006-12-24 16:38:45 +03:00
|
|
|
def scm
|
2012-01-16 21:52:54 +04:00
|
|
|
unless @scm
|
|
|
|
@scm = self.scm_adapter.new(url, root_url,
|
2011-02-24 08:58:59 +03:00
|
|
|
login, password, path_encoding)
|
2012-01-16 21:52:54 +04:00
|
|
|
if root_url.blank? && @scm.root_url.present?
|
|
|
|
update_attribute(:root_url, @scm.root_url)
|
|
|
|
end
|
|
|
|
end
|
2007-03-18 18:48:05 +03:00
|
|
|
@scm
|
|
|
|
end
|
2011-02-24 08:58:59 +03:00
|
|
|
|
2007-06-13 00:12:05 +04:00
|
|
|
def scm_name
|
|
|
|
self.class.scm_name
|
2007-03-25 16:12:15 +04:00
|
|
|
end
|
2011-02-14 11:45:34 +03:00
|
|
|
|
2012-01-15 22:19:19 +04:00
|
|
|
def name
|
2012-01-16 02:25:20 +04:00
|
|
|
if identifier.present?
|
2012-01-15 22:19:19 +04:00
|
|
|
identifier
|
2012-01-16 02:25:20 +04:00
|
|
|
elsif is_default?
|
|
|
|
l(:field_repository_is_default)
|
2012-01-15 22:19:19 +04:00
|
|
|
else
|
|
|
|
scm_name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-26 21:41:47 +04:00
|
|
|
def identifier=(identifier)
|
|
|
|
super unless identifier_frozen?
|
|
|
|
end
|
|
|
|
|
|
|
|
def identifier_frozen?
|
|
|
|
errors[:identifier].blank? && !(new_record? || identifier.blank?)
|
|
|
|
end
|
|
|
|
|
2012-01-15 22:19:19 +04:00
|
|
|
def identifier_param
|
|
|
|
if is_default?
|
|
|
|
nil
|
|
|
|
elsif identifier.present?
|
|
|
|
identifier
|
|
|
|
else
|
|
|
|
id.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def <=>(repository)
|
|
|
|
if is_default?
|
|
|
|
-1
|
|
|
|
elsif repository.is_default?
|
|
|
|
1
|
|
|
|
else
|
2012-05-04 20:57:15 +04:00
|
|
|
identifier.to_s <=> repository.identifier.to_s
|
2012-01-15 22:19:19 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.find_by_identifier_param(param)
|
|
|
|
if param.to_s =~ /^\d+$/
|
|
|
|
find_by_id(param)
|
|
|
|
else
|
|
|
|
find_by_identifier(param)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-13 03:58:38 +04:00
|
|
|
def merge_extra_info(arg)
|
|
|
|
h = extra_info || {}
|
|
|
|
return h if arg.nil?
|
|
|
|
h.merge!(arg)
|
|
|
|
write_attribute(:extra_info, h)
|
|
|
|
end
|
|
|
|
|
2011-05-13 07:55:21 +04:00
|
|
|
def report_last_commit
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2007-06-24 23:30:38 +04:00
|
|
|
def supports_cat?
|
|
|
|
scm.supports_cat?
|
|
|
|
end
|
2007-12-02 23:58:02 +03:00
|
|
|
|
|
|
|
def supports_annotate?
|
|
|
|
scm.supports_annotate?
|
|
|
|
end
|
2011-03-16 03:49:50 +03:00
|
|
|
|
|
|
|
def supports_all_revisions?
|
|
|
|
true
|
|
|
|
end
|
2011-05-05 11:30:22 +04:00
|
|
|
|
2011-03-16 03:50:11 +03:00
|
|
|
def supports_directory_revisions?
|
|
|
|
false
|
|
|
|
end
|
2011-05-05 11:30:22 +04:00
|
|
|
|
2011-11-03 12:12:01 +04:00
|
|
|
def supports_revision_graph?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2008-06-15 19:47:28 +04:00
|
|
|
def entry(path=nil, identifier=nil)
|
|
|
|
scm.entry(path, identifier)
|
|
|
|
end
|
2011-05-05 11:30:22 +04:00
|
|
|
|
2007-06-13 00:12:05 +04:00
|
|
|
def entries(path=nil, identifier=nil)
|
2012-06-10 22:32:09 +04:00
|
|
|
entries = scm.entries(path, identifier)
|
|
|
|
load_entries_changesets(entries)
|
|
|
|
entries
|
2007-03-25 22:18:29 +04:00
|
|
|
end
|
2009-08-16 02:41:40 +04:00
|
|
|
|
|
|
|
def branches
|
|
|
|
scm.branches
|
|
|
|
end
|
|
|
|
|
|
|
|
def tags
|
|
|
|
scm.tags
|
|
|
|
end
|
|
|
|
|
|
|
|
def default_branch
|
2011-06-30 07:46:32 +04:00
|
|
|
nil
|
2009-08-16 02:41:40 +04:00
|
|
|
end
|
2011-03-16 03:49:50 +03:00
|
|
|
|
2008-07-05 12:59:04 +04:00
|
|
|
def properties(path, identifier=nil)
|
|
|
|
scm.properties(path, identifier)
|
|
|
|
end
|
2011-03-16 03:49:50 +03:00
|
|
|
|
2008-06-15 19:47:28 +04:00
|
|
|
def cat(path, identifier=nil)
|
|
|
|
scm.cat(path, identifier)
|
|
|
|
end
|
2011-03-16 03:49:50 +03:00
|
|
|
|
2008-06-08 20:28:42 +04:00
|
|
|
def diff(path, rev, rev_to)
|
|
|
|
scm.diff(path, rev, rev_to)
|
2007-03-25 16:12:15 +04:00
|
|
|
end
|
2011-01-11 19:04:07 +03:00
|
|
|
|
|
|
|
def diff_format_revisions(cs, cs_to, sep=':')
|
|
|
|
text = ""
|
|
|
|
text << cs_to.format_identifier + sep if cs_to
|
|
|
|
text << cs.format_identifier if cs
|
|
|
|
text
|
|
|
|
end
|
|
|
|
|
2008-05-24 21:58:34 +04:00
|
|
|
# Returns a path relative to the url of the repository
|
|
|
|
def relative_path(path)
|
|
|
|
path
|
|
|
|
end
|
2011-01-15 01:51:12 +03:00
|
|
|
|
2009-09-20 19:20:22 +04:00
|
|
|
# Finds and returns a revision with a number or the beginning of a hash
|
|
|
|
def find_changeset_by_name(name)
|
2011-01-15 01:51:12 +03:00
|
|
|
return nil if name.blank?
|
2012-02-23 14:11:19 +04:00
|
|
|
s = name.to_s
|
2012-12-03 22:21:32 +04:00
|
|
|
if s.match(/^\d*$/)
|
|
|
|
changesets.where("revision = ?", s).first
|
|
|
|
else
|
|
|
|
changesets.where("revision LIKE ?", s + '%').first
|
|
|
|
end
|
2009-09-20 19:20:22 +04:00
|
|
|
end
|
2011-01-15 01:51:12 +03:00
|
|
|
|
2007-06-13 00:12:05 +04:00
|
|
|
def latest_changeset
|
2012-12-03 22:21:32 +04:00
|
|
|
@latest_changeset ||= changesets.first
|
2007-06-13 00:12:05 +04:00
|
|
|
end
|
2009-08-16 02:41:40 +04:00
|
|
|
|
2009-08-17 20:32:24 +04:00
|
|
|
# Returns the latest changesets for +path+
|
|
|
|
# Default behaviour is to search in cached changesets
|
|
|
|
def latest_changesets(path, rev, limit=10)
|
|
|
|
if path.blank?
|
2013-06-12 23:13:25 +04:00
|
|
|
changesets.
|
|
|
|
reorder("#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC").
|
|
|
|
limit(limit).
|
|
|
|
preload(:user).
|
|
|
|
all
|
2009-08-17 20:32:24 +04:00
|
|
|
else
|
2013-06-12 23:13:25 +04:00
|
|
|
filechanges.
|
|
|
|
where("path = ?", path.with_leading_slash).
|
|
|
|
reorder("#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC").
|
|
|
|
limit(limit).
|
|
|
|
preload(:changeset => :user).
|
|
|
|
collect(&:changeset)
|
2009-08-17 20:32:24 +04:00
|
|
|
end
|
2009-08-16 02:41:40 +04:00
|
|
|
end
|
2011-05-05 05:30:24 +04:00
|
|
|
|
2007-04-24 17:57:27 +04:00
|
|
|
def scan_changesets_for_issue_ids
|
|
|
|
self.changesets.each(&:scan_comment_for_issue_ids)
|
|
|
|
end
|
2009-08-16 02:41:40 +04:00
|
|
|
|
2008-11-10 21:59:06 +03:00
|
|
|
# Returns an array of committers usernames and associated user_id
|
|
|
|
def committers
|
2011-05-05 05:30:24 +04:00
|
|
|
@committers ||= Changeset.connection.select_rows(
|
|
|
|
"SELECT DISTINCT committer, user_id FROM #{Changeset.table_name} WHERE repository_id = #{id}")
|
2008-11-10 21:59:06 +03:00
|
|
|
end
|
2011-05-05 05:30:24 +04:00
|
|
|
|
2008-11-10 21:59:06 +03:00
|
|
|
# Maps committers username to a user ids
|
|
|
|
def committer_ids=(h)
|
|
|
|
if h.is_a?(Hash)
|
|
|
|
committers.each do |committer, user_id|
|
|
|
|
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)
|
2014-01-09 07:34:58 +04:00
|
|
|
Changeset.where(["repository_id = ? AND committer = ?", id, committer]).
|
|
|
|
update_all("user_id = #{new_user_id.nil? ? 'NULL' : new_user_id}")
|
2008-11-10 21:59:06 +03:00
|
|
|
end
|
|
|
|
end
|
2011-05-05 05:30:24 +04:00
|
|
|
@committers = nil
|
2010-02-21 17:42:45 +03:00
|
|
|
@found_committer_users = nil
|
2008-11-10 21:59:06 +03:00
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
2011-05-05 05:30:24 +04:00
|
|
|
|
2008-11-10 21:59:06 +03:00
|
|
|
# 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
|
|
|
|
def find_committer_user(committer)
|
2010-02-21 17:42:45 +03:00
|
|
|
unless committer.blank?
|
|
|
|
@found_committer_users ||= {}
|
|
|
|
return @found_committer_users[committer] if @found_committer_users.has_key?(committer)
|
2011-05-05 05:30:24 +04:00
|
|
|
|
2010-02-21 17:42:45 +03:00
|
|
|
user = nil
|
2012-12-03 22:21:32 +04:00
|
|
|
c = changesets.where(:committer => committer).includes(:user).first
|
2008-11-10 21:59:06 +03:00
|
|
|
if c && c.user
|
2010-02-21 17:42:45 +03:00
|
|
|
user = c.user
|
2008-11-10 21:59:06 +03:00
|
|
|
elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/
|
|
|
|
username, email = $1.strip, $3
|
|
|
|
u = User.find_by_login(username)
|
|
|
|
u ||= User.find_by_mail(email) unless email.blank?
|
2010-02-21 17:42:45 +03:00
|
|
|
user = u
|
2008-11-10 21:59:06 +03:00
|
|
|
end
|
2010-02-21 17:42:45 +03:00
|
|
|
@found_committer_users[committer] = user
|
|
|
|
user
|
2008-11-10 21:59:06 +03:00
|
|
|
end
|
|
|
|
end
|
2011-02-19 04:11:48 +03:00
|
|
|
|
2011-02-28 15:09:32 +03:00
|
|
|
def repo_log_encoding
|
2011-03-01 13:27:30 +03:00
|
|
|
encoding = log_encoding.to_s.strip
|
2011-02-28 15:09:32 +03:00
|
|
|
encoding.blank? ? 'UTF-8' : encoding
|
|
|
|
end
|
|
|
|
|
2010-02-09 21:42:42 +03:00
|
|
|
# Fetches new changesets for all repositories of active projects
|
|
|
|
# Can be called periodically by an external script
|
2007-03-25 16:12:15 +04:00
|
|
|
# eg. ruby script/runner "Repository.fetch_changesets"
|
|
|
|
def self.fetch_changesets
|
2012-01-15 22:19:19 +04:00
|
|
|
Project.active.has_module(:repository).all.each do |project|
|
|
|
|
project.repositories.each do |repository|
|
2011-02-15 05:12:19 +03:00
|
|
|
begin
|
2012-01-15 22:19:19 +04:00
|
|
|
repository.fetch_changesets
|
2011-02-15 05:12:19 +03:00
|
|
|
rescue Redmine::Scm::Adapters::CommandFailed => e
|
2011-02-19 04:11:48 +03:00
|
|
|
logger.error "scm: error during fetching changesets: #{e.message}"
|
2011-02-15 05:12:19 +03:00
|
|
|
end
|
2010-02-09 21:42:42 +03:00
|
|
|
end
|
|
|
|
end
|
2006-12-24 16:38:45 +03:00
|
|
|
end
|
2011-02-19 04:11:48 +03:00
|
|
|
|
2007-04-24 17:57:27 +04:00
|
|
|
# scan changeset comments to find related and fixed issues for all repositories
|
|
|
|
def self.scan_changesets_for_issue_ids
|
2012-12-03 00:23:48 +04:00
|
|
|
all.each(&:scan_changesets_for_issue_ids)
|
2007-04-24 17:57:27 +04:00
|
|
|
end
|
2007-06-13 00:12:05 +04:00
|
|
|
|
|
|
|
def self.scm_name
|
|
|
|
'Abstract'
|
|
|
|
end
|
2011-05-05 11:30:22 +04:00
|
|
|
|
2007-06-13 00:12:05 +04:00
|
|
|
def self.available_scm
|
|
|
|
subclasses.collect {|klass| [klass.scm_name, klass.name]}
|
|
|
|
end
|
2011-02-28 15:09:32 +03:00
|
|
|
|
2007-06-13 00:12:05 +04:00
|
|
|
def self.factory(klass_name, *args)
|
|
|
|
klass = "Repository::#{klass_name}".constantize
|
|
|
|
klass.new(*args)
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
2011-02-14 11:45:34 +03:00
|
|
|
|
|
|
|
def self.scm_adapter_class
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.scm_command
|
2011-02-19 04:11:48 +03:00
|
|
|
ret = ""
|
|
|
|
begin
|
|
|
|
ret = self.scm_adapter_class.client_command if self.scm_adapter_class
|
2011-06-03 13:54:57 +04:00
|
|
|
rescue Exception => e
|
2011-02-19 04:11:48 +03:00
|
|
|
logger.error "scm: error during get command: #{e.message}"
|
|
|
|
end
|
|
|
|
ret
|
2011-02-14 11:45:34 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.scm_version_string
|
2011-02-19 04:11:48 +03:00
|
|
|
ret = ""
|
|
|
|
begin
|
|
|
|
ret = self.scm_adapter_class.client_version_string if self.scm_adapter_class
|
2011-06-03 13:54:57 +04:00
|
|
|
rescue Exception => e
|
2011-02-19 04:11:48 +03:00
|
|
|
logger.error "scm: error during get version string: #{e.message}"
|
|
|
|
end
|
|
|
|
ret
|
2011-02-14 11:45:34 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.scm_available
|
2011-02-19 04:11:48 +03:00
|
|
|
ret = false
|
|
|
|
begin
|
2011-05-05 11:30:22 +04:00
|
|
|
ret = self.scm_adapter_class.client_available if self.scm_adapter_class
|
2011-06-03 13:54:57 +04:00
|
|
|
rescue Exception => e
|
2011-02-19 04:11:48 +03:00
|
|
|
logger.error "scm: error during get scm available: #{e.message}"
|
|
|
|
end
|
|
|
|
ret
|
2011-02-14 11:45:34 +03:00
|
|
|
end
|
|
|
|
|
2012-01-15 22:19:19 +04:00
|
|
|
def set_as_default?
|
2013-06-12 23:13:25 +04:00
|
|
|
new_record? && project && Repository.where(:project_id => project.id).empty?
|
2012-01-15 22:19:19 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def check_default
|
|
|
|
if !is_default? && set_as_default?
|
|
|
|
self.is_default = true
|
|
|
|
end
|
|
|
|
if is_default? && is_default_changed?
|
2014-01-07 18:54:05 +04:00
|
|
|
Repository.where(["project_id = ?", project_id]).update_all(["is_default = ?", false])
|
2012-01-15 22:19:19 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-10 22:32:09 +04:00
|
|
|
def load_entries_changesets(entries)
|
|
|
|
if entries
|
|
|
|
entries.each do |entry|
|
|
|
|
if entry.lastrev && entry.lastrev.identifier
|
|
|
|
entry.changeset = find_changeset_by_name(entry.lastrev.identifier)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-03-14 21:59:10 +03:00
|
|
|
private
|
2011-02-24 08:58:59 +03:00
|
|
|
|
2012-02-11 18:17:47 +04:00
|
|
|
# Deletes repository data
|
2008-07-14 01:55:13 +04:00
|
|
|
def clear_changesets
|
2012-11-28 14:46:10 +04:00
|
|
|
cs = Changeset.table_name
|
2012-02-11 18:17:47 +04:00
|
|
|
ch = Change.table_name
|
|
|
|
ci = "#{table_name_prefix}changesets_issues#{table_name_suffix}"
|
|
|
|
cp = "#{table_name_prefix}changeset_parents#{table_name_suffix}"
|
|
|
|
|
2014-01-27 11:21:47 +04:00
|
|
|
connection.delete("DELETE FROM #{ch} WHERE #{ch}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
|
|
|
|
connection.delete("DELETE FROM #{ci} WHERE #{ci}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
|
|
|
|
connection.delete("DELETE FROM #{cp} WHERE #{cp}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
|
|
|
|
connection.delete("DELETE FROM #{cs} WHERE #{cs}.repository_id = #{id}")
|
2012-11-21 11:44:29 +04:00
|
|
|
clear_extra_info_of_changesets
|
|
|
|
end
|
|
|
|
|
|
|
|
def clear_extra_info_of_changesets
|
2008-07-14 01:55:13 +04:00
|
|
|
end
|
2006-12-24 16:38:45 +03:00
|
|
|
end
|