summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-07-19 17:09:32 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-07-19 17:09:32 +0800
commit0538e1e934484e76575164314fe8451374e4a4c8 (patch)
tree14402303384e28b24408d7a5b053fe63067c9649 /app
parentfba2ec45b3bf493611f2d7e7e13a21c39bc654e0 (diff)
downloadgitlab-ce-0538e1e934484e76575164314fe8451374e4a4c8.tar.gz
Support SHA for downloading artifacts:
So if we also query against SHA, we could actually support SHA. If there's a branch or tag also named like SHA this could be ambiguous, but since we could already do that in Git, I think it's probably fine, people would be aware they shouldn't use the same name anyway.
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 30e8ade99ff..c1cb1558132 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -429,12 +429,15 @@ class Project < ActiveRecord::Base
repository.commit(ref)
end
- # ref can't be HEAD or SHA, can only be branch/tag name
+ # ref can't be HEAD, can only be branch/tag name or SHA
def latest_success_pipeline_for(ref = 'master')
- pipelines.where(ref: ref).success.order(id: :desc)
+ table = Ci::Pipeline.quoted_table_name
+ # TODO: Use `where(ref: ref).or(sha: ref)` in Rails 5
+ pipelines.where("#{table}.ref = ? OR #{table}.sha = ?", ref, ref).
+ success.order(id: :desc)
end
- # ref can't be HEAD or SHA, can only be branch/tag name
+ # ref can't be HEAD, can only be branch/tag name or SHA
def latest_success_builds_for(ref = 'master')
Ci::Build.joins(:pipeline).
merge(latest_success_pipeline_for(ref)).