diff options
| author | Lin Jen-Shin <godfat@godfat.org> | 2016-08-19 17:42:49 +0800 |
|---|---|---|
| committer | Lin Jen-Shin <godfat@godfat.org> | 2016-08-19 17:42:49 +0800 |
| commit | 1aba3a5c0e7c2b727f4317aab19bbc662f0fd727 (patch) | |
| tree | 0b834fa256ae85638c8b3d056081dcf41bd2bb63 /app/models | |
| parent | 9c9259cc6a08d8b2f8f827598aba06baae7b31f6 (diff) | |
| download | gitlab-ce-1aba3a5c0e7c2b727f4317aab19bbc662f0fd727.tar.gz | |
Unify pipeline_for(ref, nil) and pipeline_for(ref), feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5142#note_14073464
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/project.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 678fca7afd1..e97e6abfef9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1094,8 +1094,11 @@ class Project < ActiveRecord::Base !namespace.share_with_group_lock end - def pipeline_for(ref, sha = commit(ref).try(:sha)) + def pipeline_for(ref, sha = nil) + sha ||= commit(ref).try(:sha) + return unless sha + pipelines.order(id: :desc).find_by(sha: sha, ref: ref) end |
