diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-07-19 22:08:16 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-07-19 22:08:16 +0800 |
commit | 6054c855a082fd822611d358914ac20695608e5b (patch) | |
tree | d3e8ad6749159d4b8f3e6f930d062742aae751f0 | |
parent | 87604ed6ceb7d088dd4ebbc20185fe6ef46180c5 (diff) | |
download | gitlab-ce-6054c855a082fd822611d358914ac20695608e5b.tar.gz |
Only allow branches/tags, disallow SHA:
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5347#note_13170854
-rw-r--r-- | app/models/ci/pipeline.rb | 7 | ||||
-rw-r--r-- | spec/requests/api/builds_spec.rb | 8 |
2 files changed, 2 insertions, 13 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index fab91bdae5a..7efa67466c1 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -20,12 +20,9 @@ module Ci after_touch :update_state after_save :keep_around_commits - # ref can't be HEAD, can only be branch/tag name or SHA + # ref can't be HEAD or SHA, can only be branch/tag name scope :latest_successful_for, ->(ref) do - table = quoted_table_name - # TODO: Use `where(ref: ref).or(sha: ref)` in Rails 5 - where("#{table}.ref = ? OR #{table}.sha = ?", ref, ref). - success.order(id: :desc) + where(ref: ref).success.order(id: :desc) end def self.truncate_sha(sha) diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb index 47bcc0eebdd..20d3ed61123 100644 --- a/spec/requests/api/builds_spec.rb +++ b/spec/requests/api/builds_spec.rb @@ -255,14 +255,6 @@ describe API::API, api: true do create(:ci_build, status, :artifacts, pipeline: new_pipeline) end - context 'with sha' do - before do - get path_from_ref(pipeline.sha) - end - - it('gives the file') { verify } - end - context 'with regular branch' do before do pipeline.update(ref: 'master', |