summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG19
-rw-r--r--app/models/blob.rb4
-rw-r--r--app/models/commit.rb4
-rw-r--r--app/views/projects/builds/_sidebar.html.haml2
-rw-r--r--config/initializers/sidekiq.rb1
-rw-r--r--doc/ci/docker/using_docker_build.md2
-rw-r--r--lib/banzai/filter/relative_link_filter.rb2
-rw-r--r--lib/gitlab/sidekiq_middleware/request_store_middleware.rb13
-rw-r--r--lib/tasks/gitlab/db.rake7
-rw-r--r--spec/features/builds_spec.rb30
-rw-r--r--spec/finders/branches_finder_spec.rb2
-rw-r--r--spec/lib/banzai/filter/relative_link_filter_spec.rb25
-rw-r--r--spec/models/blob_spec.rb16
-rw-r--r--spec/models/commit_spec.rb1
-rw-r--r--spec/support/test_env.rb3
15 files changed, 111 insertions, 20 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 534f57cb08e..181829a86a5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,22 +1,27 @@
Please view this file on the master branch, on stable branches it's out of date.
v 8.11.0 (unreleased)
- - Remove magic comments (`# encoding: UTF-8`) from Ruby files !5456 (winniehell)
+ - Remove magic comments (`# encoding: UTF-8`) from Ruby files. !5456 (winniehell)
- Fix CI status icon link underline (ClemMakesApps)
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
+ - Add support for using RequestStore within Sidekiq tasks via SIDEKIQ_REQUEST_STORE env variable
- Limit git rev-list output count to one in forced push check
- - Add green outline to New Branch button !5447 (winniehell)
+ - Add green outline to New Branch button. !5447 (winniehell)
- Retrieve rendered HTML from cache in one request
- Nokogiri's various parsing methods are now instrumented
- - Make fork counter always clickable !5463 (winniehell)
- - Load project invited groups and members eagerly in ProjectTeam#fetch_members
+ - Make fork counter always clickable. !5463 (winniehell)
+ - Remove `search_id` of labels dropdown filter to fix 'Missleading URI for labels in Merge Requests and Issues view'. !5368 (Scott Le)
+ - Load project invited groups and members eagerly in `ProjectTeam#fetch_members`
- Add GitLab Workhorse version to admin dashboard (Katarzyna Kobierska Ula Budziszewska)
- - Add ES6 gem
+ - Add the `sprockets-es6` gem
v 8.10.2 (unreleased)
- User can now search branches by name. !5144
- Fix backup restore. !5459
+ - Disable MySQL foreign key checks before dropping all tables. !5472
- Use project ID in repository cache to prevent stale data from persisting across projects. !5460
+ - Ensure relative paths for video are rewritten as we do for images. !5474
+ - Ensure current user can retry a build before showing the 'Retry' button. !5476
v 8.10.1
- Refactor repository storages documentation. !5428
@@ -26,10 +31,6 @@ v 8.10.1
- Fix bug where replies to commit notes displayed in the MR discussion tab wouldn't show up on the commit page. !5446
- Ignore invalid trusted proxies in X-Forwarded-For header. !5454
- Add links to the real markdown.md file for all GFM examples. !5458
- - Remove `search_id` of labels dropdown filter to fix 'Missleading URI for labels in Merge Requests and Issues view' !5368 (Scott Le)
-
-v 8.10.1 (unreleased)
- - Fix bug where replies to commit notes displayed in the MR discussion tab wouldn't show up on the commit page
v 8.10.0
- Fix profile activity heatmap to show correct day name (eanplatter)
diff --git a/app/models/blob.rb b/app/models/blob.rb
index 4279ea2ce57..0df2805e448 100644
--- a/app/models/blob.rb
+++ b/app/models/blob.rb
@@ -31,6 +31,10 @@ class Blob < SimpleDelegator
text? && language && language.name == 'SVG'
end
+ def video?
+ UploaderHelper::VIDEO_EXT.include?(extname.downcase.delete('.'))
+ end
+
def to_partial_path
if lfs_pointer?
'download'
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 2ef3973c160..f80f1063406 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -295,8 +295,8 @@ class Commit
def uri_type(path)
entry = @raw.tree.path(path)
if entry[:type] == :blob
- blob = Gitlab::Git::Blob.new(name: entry[:name])
- blob.image? ? :raw : :blob
+ blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name]))
+ blob.image? || blob.video? ? :raw : :blob
else
entry[:type]
end
diff --git a/app/views/projects/builds/_sidebar.html.haml b/app/views/projects/builds/_sidebar.html.haml
index dc57b49f27a..b89183c40dc 100644
--- a/app/views/projects/builds/_sidebar.html.haml
+++ b/app/views/projects/builds/_sidebar.html.haml
@@ -40,7 +40,7 @@
.block{ class: ("block-first" if !@build.coverage && !(can?(current_user, :read_build, @project) && (@build.artifacts? || @build.artifacts_expired?))) }
.title
Build details
- - if @build.retryable?
+ - if can?(current_user, :update_build, @build) && @build.retryable?
= link_to "Retry", retry_namespace_project_build_path(@project.namespace, @project, @build), class: 'pull-right', method: :post
- if @build.merge_request
%p.build-detail-row
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
index 5e839327e7a..cf49ec2194c 100644
--- a/config/initializers/sidekiq.rb
+++ b/config/initializers/sidekiq.rb
@@ -7,6 +7,7 @@ Sidekiq.configure_server do |config|
config.server_middleware do |chain|
chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if ENV['SIDEKIQ_LOG_ARGUMENTS']
chain.add Gitlab::SidekiqMiddleware::MemoryKiller if ENV['SIDEKIQ_MEMORY_KILLER_MAX_RSS']
+ chain.add Gitlab::SidekiqMiddleware::RequestStoreMiddleware unless ENV['SIDEKIQ_REQUEST_STORE'] == '0'
end
# Sidekiq-cron: load recurring jobs from gitlab.yml
diff --git a/doc/ci/docker/using_docker_build.md b/doc/ci/docker/using_docker_build.md
index 7f83f846454..0f64137a8a9 100644
--- a/doc/ci/docker/using_docker_build.md
+++ b/doc/ci/docker/using_docker_build.md
@@ -38,7 +38,7 @@ GitLab Runner then executes build scripts as the `gitlab-runner` user.
$ sudo gitlab-ci-multi-runner register -n \
--url https://gitlab.com/ci \
--registration-token REGISTRATION_TOKEN \
- --executor shell
+ --executor shell \
--description "My Runner"
```
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb
index 21ed0410f7f..337fb50317d 100644
--- a/lib/banzai/filter/relative_link_filter.rb
+++ b/lib/banzai/filter/relative_link_filter.rb
@@ -20,7 +20,7 @@ module Banzai
process_link_attr el.attribute('href')
end
- doc.search('img').each do |el|
+ doc.css('img, video').each do |el|
process_link_attr el.attribute('src')
end
diff --git a/lib/gitlab/sidekiq_middleware/request_store_middleware.rb b/lib/gitlab/sidekiq_middleware/request_store_middleware.rb
new file mode 100644
index 00000000000..b1fa0e3cb4e
--- /dev/null
+++ b/lib/gitlab/sidekiq_middleware/request_store_middleware.rb
@@ -0,0 +1,13 @@
+module Gitlab
+ module SidekiqMiddleware
+ class RequestStoreMiddleware
+ def call(worker, job, queue)
+ RequestStore.begin!
+ yield
+ ensure
+ RequestStore.end!
+ RequestStore.clear!
+ end
+ end
+ end
+end
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index 0ec19e1a625..7c96bc864ce 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -25,6 +25,10 @@ namespace :gitlab do
desc 'Drop all tables'
task :drop_tables => :environment do
connection = ActiveRecord::Base.connection
+
+ # If MySQL, turn off foreign key checks
+ connection.execute('SET FOREIGN_KEY_CHECKS=0') if Gitlab::Database.mysql?
+
tables = connection.tables
tables.delete 'schema_migrations'
# Truncate schema_migrations to ensure migrations re-run
@@ -35,6 +39,9 @@ namespace :gitlab do
# MySQL: http://dev.mysql.com/doc/refman/5.7/en/drop-table.html
# Add `IF EXISTS` because cascade could have already deleted a table.
tables.each { |t| connection.execute("DROP TABLE IF EXISTS #{connection.quote_table_name(t)} CASCADE") }
+
+ # If MySQL, re-enable foreign key checks
+ connection.execute('SET FOREIGN_KEY_CHECKS=1') if Gitlab::Database.mysql?
end
desc 'Configures the database by running migrate, or by loading the schema and seeding if needed'
diff --git a/spec/features/builds_spec.rb b/spec/features/builds_spec.rb
index cab3dc1d167..0cfeb2e57d8 100644
--- a/spec/features/builds_spec.rb
+++ b/spec/features/builds_spec.rb
@@ -199,9 +199,13 @@ describe "Builds" do
click_link 'Retry'
end
- it { expect(page.status_code).to eq(200) }
- it { expect(page).to have_content 'pending' }
- it { expect(page).to have_content 'Cancel' }
+ it 'shows the right status and buttons' do
+ expect(page).to have_http_status(200)
+ expect(page).to have_content 'pending'
+ page.within('aside.right-sidebar') do
+ expect(page).to have_content 'Cancel'
+ end
+ end
end
context "Build from other project" do
@@ -212,7 +216,25 @@ describe "Builds" do
page.driver.post(retry_namespace_project_build_path(@project.namespace, @project, @build2))
end
- it { expect(page.status_code).to eq(404) }
+ it { expect(page).to have_http_status(404) }
+ end
+
+ context "Build that current user is not allowed to retry" do
+ before do
+ @build.run!
+ @build.cancel!
+ @project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
+
+ logout_direct
+ login_with(create(:user))
+ visit namespace_project_build_path(@project.namespace, @project, @build)
+ end
+
+ it 'does not show the Retry button' do
+ page.within('aside.right-sidebar') do
+ expect(page).not_to have_content 'Retry'
+ end
+ end
end
end
diff --git a/spec/finders/branches_finder_spec.rb b/spec/finders/branches_finder_spec.rb
index 9c9763d746b..dd85203a038 100644
--- a/spec/finders/branches_finder_spec.rb
+++ b/spec/finders/branches_finder_spec.rb
@@ -20,7 +20,7 @@ describe BranchesFinder do
result = branches_finder.execute
- expect(result.first.name).to eq('expand-collapse-lines')
+ expect(result.first.name).to eq('video')
end
it 'sorts by last_updated' do
diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb
index 2401875a057..9921171f2aa 100644
--- a/spec/lib/banzai/filter/relative_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb
@@ -17,6 +17,10 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do
%(<img src="#{path}" />)
end
+ def video(path)
+ %(<video src="#{path}"></video>)
+ end
+
def link(path)
%(<a href="#{path}">#{path}</a>)
end
@@ -37,6 +41,12 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do
doc = filter(image('files/images/logo-black.png'))
expect(doc.at_css('img')['src']).to eq 'files/images/logo-black.png'
end
+
+ it 'does not modify any relative URL in video' do
+ doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video')
+
+ expect(doc.at_css('video')['src']).to eq 'files/videos/intro.mp4'
+ end
end
shared_examples :relative_to_requested do
@@ -111,11 +121,26 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do
end
it 'rebuilds relative URL for an image in the repo' do
+ doc = filter(image('files/images/logo-black.png'))
+
+ expect(doc.at_css('img')['src']).
+ to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png"
+ end
+
+ it 'rebuilds relative URL for link to an image in the repo' do
doc = filter(link('files/images/logo-black.png'))
+
expect(doc.at_css('a')['href']).
to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png"
end
+ it 'rebuilds relative URL for a video in the repo' do
+ doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video')
+
+ expect(doc.at_css('video')['src']).
+ to eq "/#{project_path}/raw/video/files/videos/intro.mp4"
+ end
+
it 'does not modify relative URL with an anchor only' do
doc = filter(link('#section-1'))
expect(doc.at_css('a')['href']).to eq '#section-1'
diff --git a/spec/models/blob_spec.rb b/spec/models/blob_spec.rb
index 78e95c8fac5..1e5d6a34f83 100644
--- a/spec/models/blob_spec.rb
+++ b/spec/models/blob_spec.rb
@@ -33,6 +33,22 @@ describe Blob do
end
end
+ describe '#video?' do
+ it 'is falsey with image extension' do
+ git_blob = Gitlab::Git::Blob.new(name: 'image.png')
+
+ expect(described_class.decorate(git_blob)).not_to be_video
+ end
+
+ UploaderHelper::VIDEO_EXT.each do |ext|
+ it "is truthy when extension is .#{ext}" do
+ git_blob = Gitlab::Git::Blob.new(name: "video.#{ext}")
+
+ expect(described_class.decorate(git_blob)).to be_video
+ end
+ end
+ end
+
describe '#to_partial_path' do
def stubbed_blob(overrides = {})
overrides.reverse_merge!(
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index ba02d5fe977..ec1544bf815 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -212,6 +212,7 @@ eos
it 'returns the URI type at the given path' do
expect(commit.uri_type('files/html')).to be(:tree)
expect(commit.uri_type('files/images/logo-black.png')).to be(:raw)
+ expect(project.commit('video').uri_type('files/videos/intro.mp4')).to be(:raw)
expect(commit.uri_type('files/js/application.js')).to be(:blob)
end
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index 83f2ad96fd8..3735abe2302 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -20,7 +20,8 @@ module TestEnv
'gitattributes' => '5a62481',
'expand-collapse-diffs' => '4842455',
'expand-collapse-files' => '025db92',
- 'expand-collapse-lines' => '238e82d'
+ 'expand-collapse-lines' => '238e82d',
+ 'video' => '8879059'
}
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily