BigW Consortium Gitlab

Commit 4faf46e8 by Mark Fletcher

Merge branch '10-5-stable-prepare-rc6' into '10-5-stable'

Prepare 10.5 RC6 release See merge request gitlab-org/gitlab-ce!17111
parents 7542306b f3af0652
......@@ -14,7 +14,7 @@ export default () => {
$('#tree-slider').waitForImages(() =>
ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath));
const commitPipelineStatusEl = document.getElementById('commit-pipeline-status');
const commitPipelineStatusEl = document.querySelector('.js-commit-pipeline-status');
const statusLink = document.querySelector('.commit-actions .ci-status-link');
if (statusLink != null) {
statusLink.remove();
......
/* global katex */
import { __ } from './locale';
import flash from './flash';
// Renders math using KaTeX in any element with the
// `js-render-math` class
......@@ -8,15 +9,8 @@
// <code class="js-render-math"></div>
//
import { __ } from './locale';
import axios from './lib/utils/axios_utils';
import flash from './flash';
// Only load once
let katexLoaded = false;
// Loop over all math elements and render math
function renderWithKaTeX(elements) {
function renderWithKaTeX(elements, katex) {
elements.each(function katexElementsLoop() {
const mathNode = $('<span></span>');
const $this = $(this);
......@@ -34,30 +28,10 @@ function renderWithKaTeX(elements) {
export default function renderMath($els) {
if (!$els.length) return;
if (katexLoaded) {
renderWithKaTeX($els);
} else {
axios.get(gon.katex_css_url)
.then(() => {
const css = $('<link>', {
rel: 'stylesheet',
type: 'text/css',
href: gon.katex_css_url,
});
css.appendTo('head');
})
.then(() => axios.get(gon.katex_js_url, {
responseType: 'text',
}))
.then(({ data }) => {
// Add katex js to our document
$.globalEval(data);
})
.then(() => {
katexLoaded = true;
renderWithKaTeX($els); // Run KaTeX
})
.catch(() => flash(__('An error occurred while rendering KaTeX')));
}
Promise.all([
import(/* webpackChunkName: 'katex' */ 'katex'),
import(/* webpackChunkName: 'katex' */ 'katex/dist/katex.css'),
]).then(([katex]) => {
renderWithKaTeX($els, katex);
}).catch(() => flash(__('An error occurred while rendering KaTeX')));
}
......@@ -116,6 +116,10 @@ class Commit
raw.id
end
def project_id
project.id
end
def ==(other)
other.is_a?(self.class) && raw == other.raw
end
......
......@@ -51,7 +51,7 @@
- if commit.status(ref)
= render_commit_status(commit, ref: ref)
#commit-pipeline-status{ data: { endpoint: pipelines_project_commit_path(project, commit.id) } }
.js-commit-pipeline-status{ data: { endpoint: pipelines_project_commit_path(project, commit.id) } }
= link_to commit.short_id, link, class: "commit-sha btn btn-transparent btn-link"
= clipboard_button(text: commit.id, title: _("Copy commit SHA to clipboard"))
= link_to_browse_code(project, commit)
......
---
title: Updated the katex library
merge_request: 15864
author:
type: other
---
title: LDAP Person no longer throws exception on invalid entry
merge_request:
author:
type: fixed
......@@ -107,8 +107,6 @@ module Gitlab
config.assets.precompile << "print.css"
config.assets.precompile << "notify.css"
config.assets.precompile << "mailers/*.css"
config.assets.precompile << "katex.css"
config.assets.precompile << "katex.js"
config.assets.precompile << "xterm/xterm.css"
config.assets.precompile << "performance_bar.css"
config.assets.precompile << "lib/ace.js"
......
......@@ -154,6 +154,27 @@ var config = {
}
},
{
test: /katex.css$/,
include: /node_modules\/katex\/dist/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
name: '[name].[hash].[ext]'
}
},
],
},
{
test: /\.(eot|ttf|woff|woff2)$/,
include: /node_modules\/katex\/dist\/fonts/,
loader: 'file-loader',
options: {
name: '[name].[hash].[ext]',
}
},
{
test: /monaco-editor\/\w+\/vs\/loader\.js$/,
use: [
{ loader: 'exports-loader', options: 'l.global' },
......
......@@ -49,6 +49,7 @@ following locations:
- [Repositories](repositories.md)
- [Repository Files](repository_files.md)
- [Runners](runners.md)
- [Search](search.md)
- [Services](services.md)
- [Settings](settings.md)
- [Sidekiq metrics](sidekiq_metrics.md)
......
......@@ -737,7 +737,8 @@ Example response:
"filename": "home.md",
"id": null,
"ref": "master",
"startline": 5
"startline": 5,
"project_id": 6
}
]
```
......@@ -767,7 +768,8 @@ Example response:
"authored_date": "2013-02-18T22:02:54.000Z",
"committer_name": "angus croll",
"committer_email": "anguscroll@gmail.com",
"committed_date": "2013-02-18T22:02:54.000Z"
"committed_date": "2013-02-18T22:02:54.000Z",
"project_id": 6
}
]
```
......@@ -789,7 +791,8 @@ Example response:
"filename": "README.md",
"id": null,
"ref": "master",
"startline": 46
"startline": 46,
"project_id": 6
}
]
```
......
......@@ -274,6 +274,7 @@ module API
expose :stats, using: Entities::CommitStats, if: :stats
expose :status
expose :last_pipeline, using: 'API::Entities::PipelineBasic'
expose :project_id
end
class Branch < Grape::Entity
......@@ -1172,6 +1173,7 @@ module API
expose :id
expose :ref
expose :startline
expose :project_id
end
end
end
......@@ -11,7 +11,7 @@ module API
projects: Entities::BasicProjectDetails,
milestones: Entities::Milestone,
notes: Entities::Note,
commits: Entities::Commit,
commits: Entities::CommitDetail,
blobs: Entities::Blob,
wiki_blobs: Entities::Blob,
snippet_titles: Entities::Snippet,
......@@ -35,7 +35,7 @@ module API
def process_results(results)
case params[:scope]
when 'wiki_blobs'
paginate(results).map { |blob| Gitlab::ProjectSearchResults.parse_search_result(blob) }
paginate(results).map { |blob| Gitlab::ProjectSearchResults.parse_search_result(blob, user_project) }
when 'blobs'
paginate(results).map { |blob| blob[1] }
else
......@@ -85,9 +85,7 @@ module API
use :pagination
end
get ':id/-/search' do
group = find_group!(params[:id])
present search(group_id: group.id), with: entity
present search(group_id: user_group.id), with: entity
end
end
......@@ -106,9 +104,7 @@ module API
use :pagination
end
get ':id/-/search' do
project = find_project!(params[:id])
present search(project_id: project.id), with: entity
present search(project_id: user_project.id), with: entity
end
end
end
......
......@@ -28,7 +28,7 @@ module Gitlab
def find_by_content(query)
results = repository.search_files_by_content(query, ref).first(BATCH_SIZE)
results.map { |result| Gitlab::ProjectSearchResults.parse_search_result(result) }
results.map { |result| Gitlab::ProjectSearchResults.parse_search_result(result, project) }
end
def find_by_filename(query, except: [])
......@@ -45,7 +45,8 @@ module Gitlab
basename: File.basename(blob.path),
ref: ref,
startline: 1,
data: blob.data
data: blob.data,
project: project
)
end
end
......
......@@ -13,8 +13,6 @@ module Gitlab
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
gon.shortcuts_path = help_page_path('shortcuts')
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
gon.katex_css_url = ActionController::Base.helpers.asset_path('katex.css')
gon.katex_js_url = ActionController::Base.helpers.asset_path('katex.js')
gon.sentry_dsn = Gitlab::CurrentSettings.clientside_sentry_dsn if Gitlab::CurrentSettings.clientside_sentry_enabled
gon.gitlab_url = Gitlab.config.gitlab.url
gon.revision = Gitlab::REVISION
......
......@@ -63,8 +63,6 @@ module Gitlab
Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" }
@entry = entry
@provider = provider
validate_entry
end
def name
......@@ -117,19 +115,6 @@ module Gitlab
entry.public_send(selected_attr) # rubocop:disable GitlabSecurity/PublicSend
end
def validate_entry
allowed_attrs = self.class.ldap_attributes(config).map(&:downcase)
# Net::LDAP::Entry transforms keys to symbols. Change to strings to compare.
entry_attrs = entry.attribute_names.map { |n| n.to_s.downcase }
invalid_attrs = entry_attrs - allowed_attrs
if invalid_attrs.any?
raise InvalidEntryError,
"#{self.class.name} initialized with Net::LDAP::Entry containing invalid attributes(s): #{invalid_attrs}"
end
end
end
end
end
......@@ -42,7 +42,7 @@ module Gitlab
key, value = parsed_field.first
if value.nil?
value = open_file(tmp_path)
value = open_file(tmp_path, @request.params["#{key}.name"])
@open_files << value
else
value = decorate_params_value(value, @request.params[key], tmp_path)
......@@ -70,7 +70,7 @@ module Gitlab
case path_value
when nil
value_hash[path_key] = open_file(tmp_path)
value_hash[path_key] = open_file(tmp_path, value_hash.dig(path_key, '.name'))
@open_files << value_hash[path_key]
value_hash
when Hash
......@@ -81,8 +81,8 @@ module Gitlab
end
end
def open_file(path)
::UploadedFile.new(path, File.basename(path), 'application/octet-stream')
def open_file(path, name)
::UploadedFile.new(path, name || File.basename(path), 'application/octet-stream')
end
end
......
......@@ -41,7 +41,7 @@ module Gitlab
@commits_count ||= commits.count
end
def self.parse_search_result(result)
def self.parse_search_result(result, project = nil)
ref = nil
filename = nil
basename = nil
......@@ -66,7 +66,8 @@ module Gitlab
basename: basename,
ref: ref,
startline: startline,
data: data
data: data,
project_id: project ? project.id : nil
)
end
......
module Gitlab
class SearchResults
class FoundBlob
attr_reader :id, :filename, :basename, :ref, :startline, :data
attr_reader :id, :filename, :basename, :ref, :startline, :data, :project_id
def initialize(opts = {})
@id = opts.fetch(:id, nil)
......@@ -11,6 +11,7 @@ module Gitlab
@startline = opts.fetch(:startline, nil)
@data = opts.fetch(:data, nil)
@per_page = opts.fetch(:per_page, 20)
@project_id = opts.fetch(:project_id, nil)
end
def path
......
......@@ -55,6 +55,7 @@
"js-cookie": "^2.1.3",
"jszip": "^3.1.3",
"jszip-utils": "^0.0.2",
"katex": "^0.8.3",
"marked": "^0.3.12",
"monaco-editor": "0.10.0",
"mousetrap": "^1.4.6",
......@@ -68,6 +69,7 @@
"sanitize-html": "^1.16.1",
"select2": "3.5.2-browserify",
"sql.js": "^0.4.0",
"style-loader": "^0.19.1",
"svg4everybody": "2.1.9",
"three": "^0.84.0",
"three-orbit-controls": "^82.1.0",
......
......@@ -7,11 +7,12 @@
"data": { "type": "string" },
"filename": { "type": ["string"] },
"id": { "type": ["string", "null"] },
"project_id": { "type": "integer" },
"ref": { "type": "string" },
"startline": { "type": "integer" }
},
"required": [
"basename", "data", "filename", "id", "ref", "startline"
"basename", "data", "filename", "id", "ref", "startline", "project_id"
],
"additionalProperties": false
}
......
......@@ -4,9 +4,9 @@
{ "$ref": "basic.json" },
{
"required" : [
"stats",
"status",
"last_pipeline"
"last_pipeline",
"project_id"
],
"properties": {
"stats": { "$ref": "../commit_stats.json" },
......@@ -16,7 +16,8 @@
{ "type": "null" },
{ "$ref": "../pipeline/basic.json" }
]
}
},
"project_id": { "type": "integer" }
}
}
]
......
{
"type": "array",
"items": { "$ref": "commit/detail.json" }
}
import Vue from 'vue';
import MarkdownComponent from '~/notebook/cells/markdown.vue';
import katex from 'vendor/katex';
import katex from 'katex';
const Component = Vue.extend(MarkdownComponent);
......
......@@ -66,15 +66,6 @@ describe Gitlab::LDAP::Person do
end
end
describe '.validate_entry' do
it 'raises InvalidEntryError' do
entry['foo'] = 'bar'
expect { described_class.new(entry, 'ldapmain') }
.to raise_error(Gitlab::LDAP::Person::InvalidEntryError)
end
end
describe '#name' do
it 'uses the configured name attribute and handles values as an array' do
name = 'John Doe'
......
......@@ -5,15 +5,17 @@ require 'tempfile'
describe Gitlab::Middleware::Multipart do
let(:app) { double(:app) }
let(:middleware) { described_class.new(app) }
let(:original_filename) { 'filename' }
it 'opens top-level files' do
Tempfile.open('top-level') do |tempfile|
env = post_env({ 'file' => tempfile.path }, { 'file.name' => 'filename' }, Gitlab::Workhorse.secret, 'gitlab-workhorse')
env = post_env({ 'file' => tempfile.path }, { 'file.name' => original_filename }, Gitlab::Workhorse.secret, 'gitlab-workhorse')
expect(app).to receive(:call) do |env|
file = Rack::Request.new(env).params['file']
expect(file).to be_a(::UploadedFile)
expect(file.path).to eq(tempfile.path)
expect(file.original_filename).to eq(original_filename)
end
middleware.call(env)
......@@ -34,13 +36,14 @@ describe Gitlab::Middleware::Multipart do
it 'opens files one level deep' do
Tempfile.open('one-level') do |tempfile|
in_params = { 'user' => { 'avatar' => { '.name' => 'filename' } } }
in_params = { 'user' => { 'avatar' => { '.name' => original_filename } } }
env = post_env({ 'user[avatar]' => tempfile.path }, in_params, Gitlab::Workhorse.secret, 'gitlab-workhorse')
expect(app).to receive(:call) do |env|
file = Rack::Request.new(env).params['user']['avatar']
expect(file).to be_a(::UploadedFile)
expect(file.path).to eq(tempfile.path)
expect(file.original_filename).to eq(original_filename)
end
middleware.call(env)
......@@ -49,13 +52,14 @@ describe Gitlab::Middleware::Multipart do
it 'opens files two levels deep' do
Tempfile.open('two-levels') do |tempfile|
in_params = { 'project' => { 'milestone' => { 'themesong' => { '.name' => 'filename' } } } }
in_params = { 'project' => { 'milestone' => { 'themesong' => { '.name' => original_filename } } } }
env = post_env({ 'project[milestone][themesong]' => tempfile.path }, in_params, Gitlab::Workhorse.secret, 'gitlab-workhorse')
expect(app).to receive(:call) do |env|
file = Rack::Request.new(env).params['project']['milestone']['themesong']
expect(file).to be_a(::UploadedFile)
expect(file.path).to eq(tempfile.path)
expect(file.original_filename).to eq(original_filename)
end
middleware.call(env)
......
......@@ -295,7 +295,7 @@ describe API::Search do
get api("/projects/#{repo_project.id}/-/search", user), scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6'
end
it_behaves_like 'response is correct', schema: 'public_api/v4/commits'
it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details'
end
context 'for commits scope with project path as id' do
......@@ -303,7 +303,7 @@ describe API::Search do
get api("/projects/#{CGI.escape(repo_project.full_path)}/-/search", user), scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6'
end
it_behaves_like 'response is correct', schema: 'public_api/v4/commits'
it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details'
end
context 'for blobs scope' do
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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