diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-11-17 14:47:42 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-11-17 14:47:48 +0000 |
commit | 2686626dbf0479bd829f9f89114ec53704fc5444 (patch) | |
tree | 618d3434c3a9f3ceda9a2e4eb865712299bb9ed1 /app/models/commit_collection.rb | |
parent | 9a826fcd31430fcaec95cd31755a5712a9504833 (diff) | |
parent | e68ee8af4d981cb7b83fae76c0a94059add495fb (diff) | |
download | gitlab-ce-36400-trigger-job.tar.gz |
[ci skip] Merge branch 'master' into 36400-trigger-job36400-trigger-job
* master: (21 commits)
Changing OAuth lookup to be case insensitive
Delete orphaned fork networks in a migration
Delete the fork network when removing the last membership
Resolve "Performance issues when loading large number of wiki pages"
Exports a couple of project related code as es6 modules
Fix go-import meta data when enabled_git_access_protocol is a blank string
Add dropdowns documentation
Convert migration to populate latest merge request ID into a background migration
Set 0.69.0 instead of latest for codeclimate image
Fix hashed storage with project transfers to another namespace
De-duplicate background migration matchers defined in spec/support/migrations_helpers.rb
Update database_debugging.md
Update database_debugging.md
Move installation of apps higher
Change to Google Kubernetes Cluster and add internal links
Add Ingress description from official docs
Add info on creating your own k8s cluster from the cluster page
Add info about the installed apps in the Cluster docs
Update HA README.md to clarify GitLab support does not troubleshoot DRBD.
Optimise getting the pipeline status of commits
...
Diffstat (limited to 'app/models/commit_collection.rb')
-rw-r--r-- | app/models/commit_collection.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/models/commit_collection.rb b/app/models/commit_collection.rb new file mode 100644 index 00000000000..dd93af9df64 --- /dev/null +++ b/app/models/commit_collection.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +# A collection of Commit instances for a specific project and Git reference. +class CommitCollection + include Enumerable + + attr_reader :project, :ref, :commits + + # project - The project the commits belong to. + # commits - The Commit instances to store. + # ref - The name of the ref (e.g. "master"). + def initialize(project, commits, ref = nil) + @project = project + @commits = commits + @ref = ref + end + + def each(&block) + commits.each(&block) + end + + # Sets the pipeline status for every commit. + # + # Setting this status ahead of time removes the need for running a query for + # every commit we're displaying. + def with_pipeline_status + statuses = project.pipelines.latest_status_per_commit(map(&:id), ref) + + each do |commit| + commit.set_status_for_ref(ref, statuses[commit.id]) + end + + self + end + + def respond_to_missing?(message, inc_private = false) + commits.respond_to?(message, inc_private) + end + + # rubocop:disable GitlabSecurity/PublicSend + def method_missing(message, *args, &block) + commits.public_send(message, *args, &block) + end +end |