Skip to content
Snippets Groups Projects
Commit 021d3810 authored by Kamil Trzcinski's avatar Kamil Trzcinski
Browse files

Rename Ci::Commit to Ci::Pipeline and rename some of the ci_commit to pipeline

parent 5accd87a
No related branches found
No related tags found
No related merge requests found
Showing
with 53 additions and 53 deletions
Loading
@@ -26,9 +26,9 @@ class Projects::BuildsController < Projects::ApplicationController
Loading
@@ -26,9 +26,9 @@ class Projects::BuildsController < Projects::ApplicationController
end end
   
def show def show
@builds = @project.ci_commits.find_by_sha(@build.sha).builds.order('id DESC') @builds = @project.pipelines.find_by_sha(@build.sha).builds.order('id DESC')
@builds = @builds.where("id not in (?)", @build.id) @builds = @builds.where("id not in (?)", @build.id)
@commit = @build.commit @pipeline = @build.pipeline
   
respond_to do |format| respond_to do |format|
format.html format.html
Loading
Loading
Loading
@@ -100,7 +100,7 @@ class Projects::CommitController < Projects::ApplicationController
Loading
@@ -100,7 +100,7 @@ class Projects::CommitController < Projects::ApplicationController
end end
   
def ci_commits def ci_commits
@ci_commits ||= project.ci_commits.where(sha: commit.sha) @ci_commits ||= project.pipelines.where(sha: commit.sha)
end end
   
def ci_builds def ci_builds
Loading
Loading
Loading
@@ -119,8 +119,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -119,8 +119,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@diffs = @merge_request.compare.diffs(diff_options) if @merge_request.compare @diffs = @merge_request.compare.diffs(diff_options) if @merge_request.compare
@diff_notes_disabled = true @diff_notes_disabled = true
   
@ci_commit = @merge_request.ci_commit @pipeline = @merge_request.pipeline
@statuses = @ci_commit.statuses if @ci_commit @statuses = @pipeline.statuses if @pipeline
   
@note_counts = Note.where(commit_id: @commits.map(&:id)). @note_counts = Note.where(commit_id: @commits.map(&:id)).
group(:commit_id).count group(:commit_id).count
Loading
@@ -194,7 +194,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -194,7 +194,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
   
@merge_request.update(merge_error: nil) @merge_request.update(merge_error: nil)
   
if params[:merge_when_build_succeeds].present? && @merge_request.ci_commit && @merge_request.ci_commit.active? if params[:merge_when_build_succeeds].present? && @merge_request.pipeline && @merge_request.pipeline.active?
MergeRequests::MergeWhenBuildSucceedsService.new(@project, current_user, merge_params) MergeRequests::MergeWhenBuildSucceedsService.new(@project, current_user, merge_params)
.execute(@merge_request) .execute(@merge_request)
@status = :merge_when_build_succeeds @status = :merge_when_build_succeeds
Loading
@@ -225,10 +225,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -225,10 +225,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
   
def ci_status def ci_status
ci_commit = @merge_request.ci_commit pipeline = @merge_request.pipeline
if ci_commit if pipeline
status = ci_commit.status status = pipeline.status
coverage = ci_commit.try(:coverage) coverage = pipeline.try(:coverage)
   
status ||= "preparing" status ||= "preparing"
else else
Loading
@@ -310,8 +310,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -310,8 +310,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
   
@merge_request_diff = @merge_request.merge_request_diff @merge_request_diff = @merge_request.merge_request_diff
   
@ci_commit = @merge_request.ci_commit @pipeline = @merge_request.pipeline
@statuses = @ci_commit.statuses if @ci_commit @statuses = @ci_commit.statuses if @pipeline
   
if @merge_request.locked_long_ago? if @merge_request.locked_long_ago?
@merge_request.unlock_mr @merge_request.unlock_mr
Loading
@@ -320,8 +320,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -320,8 +320,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
   
def define_widget_vars def define_widget_vars
@ci_commit = @merge_request.ci_commit @pipeline = @merge_request.pipeline
@ci_commits = [@ci_commit].compact @pipelines = [@pipeline].compact
closes_issues closes_issues
end end
   
Loading
Loading
Loading
@@ -7,7 +7,7 @@ class Projects::PipelinesController < Projects::ApplicationController
Loading
@@ -7,7 +7,7 @@ class Projects::PipelinesController < Projects::ApplicationController
   
def index def index
@scope = params[:scope] @scope = params[:scope]
all_pipelines = project.ci_commits all_pipelines = project.pipelines
@pipelines_count = all_pipelines.count @pipelines_count = all_pipelines.count
@running_or_pending_count = all_pipelines.running_or_pending.count @running_or_pending_count = all_pipelines.running_or_pending.count
@pipelines = PipelinesFinder.new(project).execute(all_pipelines, @scope) @pipelines = PipelinesFinder.new(project).execute(all_pipelines, @scope)
Loading
@@ -15,7 +15,7 @@ class Projects::PipelinesController < Projects::ApplicationController
Loading
@@ -15,7 +15,7 @@ class Projects::PipelinesController < Projects::ApplicationController
end end
   
def new def new
@pipeline = project.ci_commits.new(ref: @project.default_branch) @pipeline = project.pipelines.new(ref: @project.default_branch)
end end
   
def create def create
Loading
@@ -50,7 +50,7 @@ class Projects::PipelinesController < Projects::ApplicationController
Loading
@@ -50,7 +50,7 @@ class Projects::PipelinesController < Projects::ApplicationController
end end
   
def pipeline def pipeline
@pipeline ||= project.ci_commits.find_by!(id: params[:id]) @pipeline ||= project.pipelines.find_by!(id: params[:id])
end end
   
def commit def commit
Loading
Loading
Loading
@@ -45,8 +45,8 @@ module Ci
Loading
@@ -45,8 +45,8 @@ module Ci
new_build.options = build.options new_build.options = build.options
new_build.commands = build.commands new_build.commands = build.commands
new_build.tag_list = build.tag_list new_build.tag_list = build.tag_list
new_build.gl_project_id = build.gl_project_id new_build.project = build.project
new_build.commit_id = build.commit_id new_build.pipeline = build.pipeline
new_build.name = build.name new_build.name = build.name
new_build.allow_failure = build.allow_failure new_build.allow_failure = build.allow_failure
new_build.stage = build.stage new_build.stage = build.stage
Loading
@@ -66,7 +66,7 @@ module Ci
Loading
@@ -66,7 +66,7 @@ module Ci
# We use around_transition to create builds for next stage as soon as possible, before the `after_*` is executed # We use around_transition to create builds for next stage as soon as possible, before the `after_*` is executed
around_transition any => [:success, :failed, :canceled] do |build, block| around_transition any => [:success, :failed, :canceled] do |build, block|
block.call block.call
build.commit.create_next_builds(build) if build.commit build.pipeline.create_next_builds(build) if build.pipeline
end end
   
after_transition any => [:success, :failed, :canceled] do |build| after_transition any => [:success, :failed, :canceled] do |build|
Loading
@@ -80,7 +80,7 @@ module Ci
Loading
@@ -80,7 +80,7 @@ module Ci
end end
   
def retried? def retried?
!self.commit.statuses.latest.include?(self) !self.pipeline.statuses.latest.include?(self)
end end
   
def retry def retry
Loading
@@ -89,7 +89,7 @@ module Ci
Loading
@@ -89,7 +89,7 @@ module Ci
   
def depends_on_builds def depends_on_builds
# Get builds of the same type # Get builds of the same type
latest_builds = self.commit.builds.latest latest_builds = self.pipeline.builds.latest
   
# Return builds from previous stages # Return builds from previous stages
latest_builds.where('stage_idx < ?', stage_idx) latest_builds.where('stage_idx < ?', stage_idx)
Loading
@@ -114,7 +114,7 @@ module Ci
Loading
@@ -114,7 +114,7 @@ module Ci
   
def merge_request def merge_request
merge_requests = MergeRequest.includes(:merge_request_diff) merge_requests = MergeRequest.includes(:merge_request_diff)
.where(source_branch: ref, source_project_id: commit.gl_project_id) .where(source_branch: ref, source_project_id: pipeline.gl_project_id)
.reorder(iid: :asc) .reorder(iid: :asc)
   
merge_requests.find do |merge_request| merge_requests.find do |merge_request|
Loading
Loading
module Ci module Ci
class Commit < ActiveRecord::Base class Pipeline < ActiveRecord::Base
extend Ci::Model extend Ci::Model
include Statuseable include Statuseable
   
Loading
@@ -47,7 +47,7 @@ module Ci
Loading
@@ -47,7 +47,7 @@ module Ci
end end
   
def short_sha def short_sha
Ci::Commit.truncate_sha(sha) Ci::Pipeline.truncate_sha(sha)
end end
   
def commit_data def commit_data
Loading
Loading
Loading
@@ -3,7 +3,7 @@ module Ci
Loading
@@ -3,7 +3,7 @@ module Ci
extend Ci::Model extend Ci::Model
belongs_to :trigger, class_name: 'Ci::Trigger' belongs_to :trigger, class_name: 'Ci::Trigger'
belongs_to :commit, class_name: 'Ci::Commit' belongs_to :commit, class_name: 'Ci::Pipeline'
has_many :builds, class_name: 'Ci::Build' has_many :builds, class_name: 'Ci::Build'
   
serialize :variables serialize :variables
Loading
Loading
Loading
@@ -214,13 +214,13 @@ class Commit
Loading
@@ -214,13 +214,13 @@ class Commit
@raw.short_id(7) @raw.short_id(7)
end end
   
def ci_commits def pipelines
@ci_commits ||= project.ci_commits.where(sha: sha) @pipeline ||= project.pipelines.where(sha: sha)
end end
   
def status def status
return @status if defined?(@status) return @status if defined?(@status)
@status ||= ci_commits.status @status ||= pipelines.status
end end
   
def revert_branch_name def revert_branch_name
Loading
Loading
Loading
@@ -4,10 +4,10 @@ class CommitStatus < ActiveRecord::Base
Loading
@@ -4,10 +4,10 @@ class CommitStatus < ActiveRecord::Base
self.table_name = 'ci_builds' self.table_name = 'ci_builds'
   
belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id
belongs_to :commit, class_name: 'Ci::Commit', touch: true belongs_to :pipeline, class_name: 'Ci::Pipeline', foreign_key: :commit_id, touch: true
belongs_to :user belongs_to :user
   
validates :commit, presence: true validates :pipeline, presence: true
   
validates_presence_of :name validates_presence_of :name
   
Loading
@@ -44,11 +44,11 @@ class CommitStatus < ActiveRecord::Base
Loading
@@ -44,11 +44,11 @@ class CommitStatus < ActiveRecord::Base
end end
   
after_transition [:pending, :running] => :success do |commit_status| after_transition [:pending, :running] => :success do |commit_status|
MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.commit.project, nil).trigger(commit_status) MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status)
end end
   
after_transition any => :failed do |commit_status| after_transition any => :failed do |commit_status|
MergeRequests::AddTodoWhenBuildFailsService.new(commit_status.commit.project, nil).execute(commit_status) MergeRequests::AddTodoWhenBuildFailsService.new(commit_status.pipeline.project, nil).execute(commit_status)
end end
end end
   
Loading
Loading
Loading
@@ -579,8 +579,8 @@ class MergeRequest < ActiveRecord::Base
Loading
@@ -579,8 +579,8 @@ class MergeRequest < ActiveRecord::Base
diverged_commits_count > 0 diverged_commits_count > 0
end end
   
def ci_commit def pipeline
@ci_commit ||= source_project.ci_commit(last_commit.id, source_branch) if last_commit && source_project @pipeline ||= source_project.pipeline(last_commit.id, source_branch) if last_commit && source_project
end end
   
def diff_refs def diff_refs
Loading
Loading
Loading
@@ -119,7 +119,7 @@ class Project < ActiveRecord::Base
Loading
@@ -119,7 +119,7 @@ class Project < ActiveRecord::Base
has_one :import_data, dependent: :destroy, class_name: "ProjectImportData" has_one :import_data, dependent: :destroy, class_name: "ProjectImportData"
   
has_many :commit_statuses, dependent: :destroy, class_name: 'CommitStatus', foreign_key: :gl_project_id has_many :commit_statuses, dependent: :destroy, class_name: 'CommitStatus', foreign_key: :gl_project_id
has_many :ci_commits, dependent: :destroy, class_name: 'Ci::Commit', foreign_key: :gl_project_id has_many :pipelines, dependent: :destroy, class_name: 'Ci::Pipeline', foreign_key: :gl_project_id
has_many :builds, class_name: 'Ci::Build', foreign_key: :gl_project_id # the builds are created from the commit_statuses has_many :builds, class_name: 'Ci::Build', foreign_key: :gl_project_id # the builds are created from the commit_statuses
has_many :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject', foreign_key: :gl_project_id has_many :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject', foreign_key: :gl_project_id
has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner' has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner'
Loading
@@ -930,12 +930,12 @@ class Project < ActiveRecord::Base
Loading
@@ -930,12 +930,12 @@ class Project < ActiveRecord::Base
!namespace.share_with_group_lock !namespace.share_with_group_lock
end end
   
def ci_commit(sha, ref) def pipeline(sha, ref)
ci_commits.order(id: :desc).find_by(sha: sha, ref: ref) pipelines.order(id: :desc).find_by(sha: sha, ref: ref)
end end
   
def ensure_ci_commit(sha, ref) def ensure_pipeline(sha, ref)
ci_commit(sha, ref) || ci_commits.create(sha: sha, ref: ref) pipeline(sha, ref) || pipelines.create(sha: sha, ref: ref)
end end
   
def enable_ci def enable_ci
Loading
Loading
module Ci module Ci
class CreatePipelineService < BaseService class CreatePipelineService < BaseService
def execute def execute
pipeline = project.ci_commits.new(params) pipeline = project.pipelines.new(params)
   
unless ref_names.include?(params[:ref]) unless ref_names.include?(params[:ref])
pipeline.errors.add(:base, 'Reference not found') pipeline.errors.add(:base, 'Reference not found')
Loading
@@ -19,7 +19,7 @@ module Ci
Loading
@@ -19,7 +19,7 @@ module Ci
end end
   
begin begin
Ci::Commit.transaction do Ci::Pipeline.transaction do
pipeline.sha = commit.id pipeline.sha = commit.id
   
unless pipeline.config_processor unless pipeline.config_processor
Loading
Loading
Loading
@@ -7,7 +7,7 @@ module Ci
Loading
@@ -7,7 +7,7 @@ module Ci
# check if ref is tag # check if ref is tag
tag = project.repository.find_tag(ref).present? tag = project.repository.find_tag(ref).present?
   
ci_commit = project.ci_commits.create(sha: commit.sha, ref: ref, tag: tag) ci_commit = project.pipelines.create(sha: commit.sha, ref: ref, tag: tag)
   
trigger_request = trigger.trigger_requests.create!( trigger_request = trigger.trigger_requests.create!(
variables: variables, variables: variables,
Loading
Loading
Loading
@@ -3,7 +3,7 @@ module Ci
Loading
@@ -3,7 +3,7 @@ module Ci
def execute(project, opts) def execute(project, opts)
sha = opts[:sha] || ref_sha(project, opts[:ref]) sha = opts[:sha] || ref_sha(project, opts[:ref])
   
ci_commits = project.ci_commits.where(sha: sha) ci_commits = project.pipelines.where(sha: sha)
ci_commits = ci_commits.where(ref: opts[:ref]) if opts[:ref] ci_commits = ci_commits.where(ref: opts[:ref]) if opts[:ref]
image_name = image_for_status(ci_commits.status) image_name = image_for_status(ci_commits.status)
   
Loading
Loading
Loading
@@ -18,7 +18,7 @@ class CreateCommitBuildsService
Loading
@@ -18,7 +18,7 @@ class CreateCommitBuildsService
return false return false
end end
   
commit = Ci::Commit.new(project: project, sha: sha, ref: ref, before_sha: before_sha, tag: tag) commit = Ci::Pipeline.new(project: project, sha: sha, ref: ref, before_sha: before_sha, tag: tag)
   
# Skip creating ci_commit when no gitlab-ci.yml is found # Skip creating ci_commit when no gitlab-ci.yml is found
unless commit.ci_yaml_file unless commit.ci_yaml_file
Loading
Loading
Loading
@@ -55,12 +55,12 @@ module MergeRequests
Loading
@@ -55,12 +55,12 @@ module MergeRequests
   
def each_merge_request(commit_status) def each_merge_request(commit_status)
merge_request_from(commit_status).each do |merge_request| merge_request_from(commit_status).each do |merge_request|
ci_commit = merge_request.ci_commit pipeline = merge_request.pipeline
   
next unless ci_commit next unless pipeline
next unless ci_commit.sha == commit_status.sha next unless pipeline.sha == commit_status.sha
   
yield merge_request, ci_commit yield merge_request, pipeline
end end
end end
end end
Loading
Loading
Loading
@@ -169,7 +169,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
Loading
@@ -169,7 +169,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
end end
   
step 'repository contains ".gitlab-ci.yml" file' do step 'repository contains ".gitlab-ci.yml" file' do
allow_any_instance_of(Ci::Commit).to receive(:ci_yaml_file).and_return(String.new) allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return(String.new)
end end
   
step 'I see commit ci info' do step 'I see commit ci info' do
Loading
Loading
Loading
@@ -50,7 +50,7 @@ module API
Loading
@@ -50,7 +50,7 @@ module API
commit = @project.commit(params[:sha]) commit = @project.commit(params[:sha])
not_found! 'Commit' unless commit not_found! 'Commit' unless commit
   
# Since the CommitStatus is attached to Ci::Commit (in the future Pipeline) # Since the CommitStatus is attached to Ci::Pipeline (in the future Pipeline)
# We need to always have the pipeline object # We need to always have the pipeline object
# To have a valid pipeline object that can be attached to specific MR # To have a valid pipeline object that can be attached to specific MR
# Other CI service needs to send `ref` # Other CI service needs to send `ref`
Loading
Loading
Loading
@@ -238,7 +238,7 @@ module API
Loading
@@ -238,7 +238,7 @@ module API
should_remove_source_branch: params[:should_remove_source_branch] should_remove_source_branch: params[:should_remove_source_branch]
} }
   
if parse_boolean(params[:merge_when_build_succeeds]) && merge_request.ci_commit && merge_request.ci_commit.active? if parse_boolean(params[:merge_when_build_succeeds]) && merge_request.pipeline && merge_request.pipeline.active?
::MergeRequests::MergeWhenBuildSucceedsService.new(merge_request.target_project, current_user, merge_params). ::MergeRequests::MergeWhenBuildSucceedsService.new(merge_request.target_project, current_user, merge_params).
execute(merge_request) execute(merge_request)
else else
Loading
Loading
Loading
@@ -60,7 +60,7 @@ module Ci
Loading
@@ -60,7 +60,7 @@ module Ci
   
class BuildTime < Chart class BuildTime < Chart
def collect def collect
commits = project.ci_commits.last(30) commits = project.pipelines.last(30)
   
commits.each do |commit| commits.each do |commit|
@labels << commit.short_sha @labels << commit.short_sha
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment