gitlab-org--gitlab-foss/app/observers/project_observer.rb

44 lines
1.1 KiB
Ruby
Raw Normal View History

class ProjectObserver < BaseObserver
def after_create(project)
return true if project.forked? || project.imported?
GitlabShellWorker.perform_async(
:add_repository,
project.path_with_namespace
)
log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"")
end
def after_update(project)
project.send_move_instructions if project.namespace_id_changed?
2013-05-24 17:07:19 -04:00
project.rename_repo if project.path_changed?
GitlabShellWorker.perform_async(
:update_repository_head,
project.path_with_namespace,
project.default_branch
) if project.default_branch_changed?
end
def before_destroy(project)
project.repository.expire_cache unless project.empty_repo?
end
def after_destroy(project)
2013-02-11 12:27:26 -05:00
GitlabShellWorker.perform_async(
2013-02-04 08:07:56 -05:00
:remove_repository,
project.path_with_namespace
2013-02-04 08:07:56 -05:00
)
2012-09-11 16:24:53 -04:00
GitlabShellWorker.perform_async(
:remove_repository,
project.path_with_namespace + ".wiki"
)
project.satellite.destroy
2012-09-11 16:24:53 -04:00
2013-02-04 08:07:56 -05:00
log_info("Project \"#{project.name}\" was removed")
2012-09-11 16:24:53 -04:00
end
end