Commit c94cff3e authored by Lin Jen-Shin's avatar Lin Jen-Shin

Prefer if over return

parent 6597c213
...@@ -431,14 +431,18 @@ class Project < ActiveRecord::Base ...@@ -431,14 +431,18 @@ class Project < ActiveRecord::Base
def builds_for(build_name, ref = 'HEAD') def builds_for(build_name, ref = 'HEAD')
ct = commit(ref) ct = commit(ref)
return builds.none unless ct
sha = commit(ref).sha if ct.nil?
builds.none
else
sha = ct.sha
builds.joins(:pipeline). builds.joins(:pipeline).
merge(Ci::Pipeline.where(sha: sha)). merge(Ci::Pipeline.where(sha: sha)).
where(name: build_name) where(name: build_name)
end end
end
def merge_base_commit(first_commit_id, second_commit_id) def merge_base_commit(first_commit_id, second_commit_id)
sha = repository.merge_base(first_commit_id, second_commit_id) sha = repository.merge_base(first_commit_id, second_commit_id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment