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

Prefer if over return

parent 6597c213
...@@ -431,13 +431,17 @@ class Project < ActiveRecord::Base ...@@ -431,13 +431,17 @@ 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
builds.joins(:pipeline). else
merge(Ci::Pipeline.where(sha: sha)). sha = ct.sha
where(name: build_name)
builds.joins(:pipeline).
merge(Ci::Pipeline.where(sha: sha)).
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)
......
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