diff options
author | Valery Sizov <valery@gitlab.com> | 2015-04-17 14:15:24 +0000 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-04-17 14:15:24 +0000 |
commit | f73c162835c11a357baf59430fddceb02e22259b (patch) | |
tree | 0604a37a22667a57f286f2bb773b4f4e9435e32e | |
parent | cca6ded9fd1874863a265ca4d96c243e637ec3de (diff) | |
parent | ba97b86868c14c7e4e18bada4247f57bd544c837 (diff) | |
download | gitlab-ci-f73c162835c11a357baf59430fddceb02e22259b.tar.gz |
Merge branch 'cleanup' into 'master'
Cleanup the build model
https://dev.gitlab.org/gitlab/gitlab-ci/issues/202
See merge request !67
-rw-r--r-- | app/controllers/builds_controller.rb | 2 | ||||
-rw-r--r-- | app/models/build.rb | 20 | ||||
-rw-r--r-- | app/models/commit.rb | 1 | ||||
-rw-r--r-- | app/models/job.rb | 1 | ||||
-rw-r--r-- | db/migrate/20150417000045_cleanup_the_build_model.rb | 9 | ||||
-rw-r--r-- | db/schema.rb | 9 | ||||
-rw-r--r-- | spec/factories/builds.rb | 7 | ||||
-rw-r--r-- | spec/models/build_spec.rb | 7 | ||||
-rw-r--r-- | spec/models/job_spec.rb | 1 |
9 files changed, 17 insertions, 40 deletions
diff --git a/app/controllers/builds_controller.rb b/app/controllers/builds_controller.rb index a1cb017..fc9ec18 100644 --- a/app/controllers/builds_controller.rb +++ b/app/controllers/builds_controller.rb @@ -49,7 +49,7 @@ class BuildsController < ApplicationController end def status - render json: @build.to_json(only: [:status, :id, :sha, :coverage]) + render json: @build.to_json(only: [:status, :id, :sha, :coverage], methods: :sha) end def cancel diff --git a/app/models/build.rb b/app/models/build.rb index 3d776ba..c9f1230 100644 --- a/app/models/build.rb +++ b/app/models/build.rb @@ -4,20 +4,15 @@ # # id :integer not null, primary key # project_id :integer -# ref :string(255) # status :string(255) # finished_at :datetime # trace :text # created_at :datetime # updated_at :datetime -# sha :string(255) # started_at :datetime -# tmp_file :string(255) -# before_sha :string(255) -# push_data :text # runner_id :integer -# coverage :float # commit_id :integer +# coverage :float # commands :text # job_id :integer # @@ -79,7 +74,6 @@ class Build < ActiveRecord::Base new_build.job_id = build.job_id new_build.commit_id = build.commit_id - new_build.ref = build.ref new_build.project_id = build.project_id new_build.save new_build @@ -133,7 +127,7 @@ class Build < ActiveRecord::Base state :canceled, value: 'canceled' end - delegate :sha, :short_sha, :before_sha, + delegate :sha, :short_sha, :before_sha, :ref, to: :commit, prefix: false def trace_html @@ -219,16 +213,6 @@ class Build < ActiveRecord::Base end end - def ref - build_ref = read_attribute(:ref) - - if build_ref.present? - build_ref - else - commit.ref - end - end - def for_tag? if job && job.build_tags true diff --git a/app/models/commit.rb b/app/models/commit.rb index 5f1aa92..6817a9e 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -117,7 +117,6 @@ class Commit < ActiveRecord::Base build.tag_list = job.tag_list build.project_id = project_id build.job = job - build.ref = ref build.save build end diff --git a/app/models/job.rb b/app/models/job.rb index 14cc344..110c96d 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -13,6 +13,7 @@ # build_tags :boolean default(FALSE), not null # job_type :string(255) default("parallel") # refs :string(255) +# deleted_at :datetime # class Job < ActiveRecord::Base diff --git a/db/migrate/20150417000045_cleanup_the_build_model.rb b/db/migrate/20150417000045_cleanup_the_build_model.rb new file mode 100644 index 0000000..1ade714 --- /dev/null +++ b/db/migrate/20150417000045_cleanup_the_build_model.rb @@ -0,0 +1,9 @@ +class CleanupTheBuildModel < ActiveRecord::Migration + def change + remove_column :builds, :push_data + remove_column :builds, :before_sha + remove_column :builds, :ref + remove_column :builds, :sha + remove_column :builds, :tmp_file + end +end diff --git a/db/schema.rb b/db/schema.rb index 65a1032..f16ae4c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,24 +11,19 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150415142013) do +ActiveRecord::Schema.define(version: 20150417000045) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "builds", force: true do |t| t.integer "project_id" - t.string "ref" t.string "status" t.datetime "finished_at" t.text "trace" t.datetime "created_at" t.datetime "updated_at" - t.string "sha" t.datetime "started_at" - t.string "tmp_file" - t.string "before_sha" - t.text "push_data" t.integer "runner_id" t.integer "commit_id" t.float "coverage" @@ -38,10 +33,8 @@ ActiveRecord::Schema.define(version: 20150415142013) do add_index "builds", ["commit_id"], name: "index_builds_on_commit_id", using: :btree add_index "builds", ["project_id", "commit_id"], name: "index_builds_on_project_id_and_commit_id", using: :btree - add_index "builds", ["project_id", "sha"], name: "index_builds_on_project_id_and_sha", using: :btree add_index "builds", ["project_id"], name: "index_builds_on_project_id", using: :btree add_index "builds", ["runner_id"], name: "index_builds_on_runner_id", using: :btree - add_index "builds", ["sha"], name: "index_builds_on_sha", using: :btree create_table "commits", force: true do |t| t.integer "project_id" diff --git a/spec/factories/builds.rb b/spec/factories/builds.rb index 369f4ee..a722a05 100644 --- a/spec/factories/builds.rb +++ b/spec/factories/builds.rb @@ -4,20 +4,15 @@ # # id :integer not null, primary key # project_id :integer -# ref :string(255) # status :string(255) # finished_at :datetime # trace :text # created_at :datetime # updated_at :datetime -# sha :string(255) # started_at :datetime -# tmp_file :string(255) -# before_sha :string(255) -# push_data :text # runner_id :integer -# coverage :float # commit_id :integer +# coverage :float # commands :text # job_id :integer # diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb index de0e0b9..073a215 100644 --- a/spec/models/build_spec.rb +++ b/spec/models/build_spec.rb @@ -4,20 +4,15 @@ # # id :integer not null, primary key # project_id :integer -# ref :string(255) # status :string(255) # finished_at :datetime # trace :text # created_at :datetime # updated_at :datetime -# sha :string(255) # started_at :datetime -# tmp_file :string(255) -# before_sha :string(255) -# push_data :text # runner_id :integer -# coverage :float # commit_id :integer +# coverage :float # commands :text # job_id :integer # diff --git a/spec/models/job_spec.rb b/spec/models/job_spec.rb index 96221d7..d993139 100644 --- a/spec/models/job_spec.rb +++ b/spec/models/job_spec.rb @@ -13,6 +13,7 @@ # build_tags :boolean default(FALSE), not null # job_type :string(255) default("parallel") # refs :string(255) +# deleted_at :datetime # require 'spec_helper' |