diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-10-02 13:39:31 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-10-02 13:39:31 +0300 |
commit | c7e323438e97bee1ed9171897f6ff2b3d44e08cb (patch) | |
tree | eee3836e72403b9f0a7612bf8ee9eeb500e0a205 /app/models | |
parent | 2fa89a3dc6a7580969203e43808048b79f172c0c (diff) | |
parent | 3515cb9b2de4b6c1018fec35b0513eb7dc33dc66 (diff) |
Merge branch 'ensure-ci-project' into 'master'
Ensure GitLab CI project exists when CI service is activated manually
When I check activeated checkbox in project services for GitLab CI it
cause half-working state when gitlab_ci_project is missing. This patch
fixes it until we have proper behaviour implemented later
This fix also bring us to the point when fork of project is a bit broken and have unnecessary code so I made cleanup.
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
cc @ayufan
See merge request !1491
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 6 | ||||
-rw-r--r-- | app/models/project_services/gitlab_ci_service.rb | 20 |
2 files changed, 6 insertions, 20 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 8527fa29808..fa7690d8fd5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -751,13 +751,9 @@ class Project < ActiveRecord::Base gitlab_ci_project || create_gitlab_ci_project end - def enable_ci(user) - # Enable service + def enable_ci service = gitlab_ci_service || create_gitlab_ci_service service.active = true service.save - - # Create Ci::Project - Ci::CreateProjectService.new.execute(user, self) end end diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb index 436d4cfed81..6d2cf79b691 100644 --- a/app/models/project_services/gitlab_ci_service.rb +++ b/app/models/project_services/gitlab_ci_service.rb @@ -22,12 +22,17 @@ class GitlabCiService < CiService include Gitlab::Application.routes.url_helpers after_save :compose_service_hook, if: :activated? + after_save :ensure_gitlab_ci_project, if: :activated? def compose_service_hook hook = service_hook || build_service_hook hook.save end + def ensure_gitlab_ci_project + project.ensure_gitlab_ci_project + end + def supported_events %w(push tag_push) end @@ -67,21 +72,6 @@ class GitlabCiService < CiService :error end - def fork_registration(new_project, current_user) - params = OpenStruct.new({ - id: new_project.id, - default_branch: new_project.default_branch - }) - - ci_project = Ci::Project.find_by!(gitlab_id: project.id) - - Ci::CreateProjectService.new.execute( - current_user, - params, - ci_project - ) - end - def commit_coverage(sha, ref) get_ci_commit(sha, ref).coverage rescue ActiveRecord::RecordNotFound |