Move directory with project. Fixed all related path methods to use namespace
This commit is contained in:
parent
e29ccece33
commit
71214bee75
9 changed files with 55 additions and 10 deletions
|
@ -3,7 +3,7 @@ class IssueObserver < ActiveRecord::Observer
|
|||
|
||||
def after_create(issue)
|
||||
if issue.assignee && issue.assignee != current_user
|
||||
Notify.new_issue_email(issue.id).deliver
|
||||
Notify.new_issue_email(issue.id).deliver
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -14,8 +14,8 @@ class IssueObserver < ActiveRecord::Observer
|
|||
status = 'closed' if issue.is_being_closed?
|
||||
status = 'reopened' if issue.is_being_reopened?
|
||||
if status
|
||||
Note.create_status_change_note(issue, current_user, status)
|
||||
[issue.author, issue.assignee].compact.each do |recipient|
|
||||
Note.create_status_change_note(issue, current_user, status)
|
||||
[issue.author, issue.assignee].compact.each do |recipient|
|
||||
Notify.issue_status_changed_email(recipient.id, issue.id, status, current_user)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
class ProjectObserver < ActiveRecord::Observer
|
||||
def after_save(project)
|
||||
project.update_repository
|
||||
|
||||
# Move repository if namespace changed
|
||||
if project.namespace_id_changed?
|
||||
move_project(project)
|
||||
end
|
||||
end
|
||||
|
||||
def after_destroy(project)
|
||||
|
@ -18,4 +23,19 @@ class ProjectObserver < ActiveRecord::Observer
|
|||
def log_info message
|
||||
Gitlab::AppLogger.info message
|
||||
end
|
||||
|
||||
def move_project(project)
|
||||
old_dir = Namespace.find_by_id(project.namespace_id_was).try(:code) || ''
|
||||
new_dir = Namespace.find_by_id(project.namespace_id).try(:code) || ''
|
||||
|
||||
# Create new dir if missing
|
||||
new_dir_path = File.join(Gitlab.config.git_base_path, new_dir)
|
||||
Dir.mkdir(new_dir_path) unless File.exists?(new_dir_path)
|
||||
|
||||
old_path = File.join(Gitlab.config.git_base_path, old_dir, "#{project.path}.git")
|
||||
new_path = File.join(new_dir_path, "#{project.path}.git")
|
||||
|
||||
binding.pry
|
||||
`mv #{old_path} #{new_path}`
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue