Commit d102aa13 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'ce-to-ee-2018-07-18' into 'master'

CE upstream - 2018-07-18 03:21 UTC

Closes gitlab-ce#49133

See merge request gitlab-org/gitlab-ee!6566
parents 9505651b 16ec9cf7
......@@ -85,6 +85,9 @@ export default {
}
return __('Show latest version');
},
canCurrentUserFork() {
return this.currentUser.canFork === true && this.currentUser.canCreateMergeRequest;
},
},
watch: {
diffViewType() {
......@@ -192,7 +195,7 @@ export default {
v-for="file in diffFiles"
:key="file.newPath"
:file="file"
:current-user="currentUser"
:can-current-user-fork="canCurrentUserFork"
/>
</div>
<no-changes v-else />
......
......@@ -18,8 +18,8 @@ export default {
type: Object,
required: true,
},
currentUser: {
type: Object,
canCurrentUserFork: {
type: Boolean,
required: true,
},
},
......@@ -87,7 +87,7 @@ export default {
class="diff-file file-holder"
>
<diff-file-header
:current-user="currentUser"
:can-current-user-fork="canCurrentUserFork"
:diff-file="file"
:collapsible="true"
:expanded="!isCollapsed"
......
......@@ -39,8 +39,8 @@ export default {
required: false,
default: true,
},
currentUser: {
type: Object,
canCurrentUserFork: {
type: Boolean,
required: true,
},
},
......@@ -228,7 +228,7 @@ export default {
<edit-button
v-if="!diffFile.deletedFile"
:current-user="currentUser"
:can-current-user-fork="canCurrentUserFork"
:edit-path="diffFile.editPath"
:can-modify-blob="diffFile.canModifyBlob"
@showForkMessage="showForkMessage"
......
......@@ -13,12 +13,8 @@ export default {
noteForm,
},
props: {
diffFile: {
type: Object,
required: true,
},
diffLines: {
type: Array,
diffFileHash: {
type: String,
required: true,
},
line: {
......@@ -40,6 +36,7 @@ export default {
noteableData: state => state.notes.noteableData,
diffViewType: state => state.diffs.diffViewType,
}),
...mapGetters('diffs', ['getDiffFileByHash']),
...mapGetters(['isLoggedIn', 'noteableType', 'getNoteableData', 'getNotesDataByProp']),
},
mounted() {
......@@ -68,13 +65,14 @@ export default {
});
},
handleSaveNote(note) {
const selectedDiffFile = this.getDiffFileByHash(this.diffFileHash);
const postData = getNoteFormData({
note,
noteableData: this.noteableData,
noteableType: this.noteableType,
noteTargetLine: this.noteTargetLine,
diffViewType: this.diffViewType,
diffFile: this.diffFile,
diffFile: selectedDiffFile,
linePosition: this.position,
});
......
......@@ -24,8 +24,12 @@ export default {
type: Object,
required: true,
},
diffFile: {
type: Object,
fileHash: {
type: String,
required: true,
},
contextLinesPath: {
type: String,
required: true,
},
diffViewType: {
......@@ -120,14 +124,14 @@ export default {
:class="classNameMap"
>
<diff-line-gutter-content
:file-hash="diffFile.fileHash"
:file-hash="fileHash"
:context-lines-path="contextLinesPath"
:line-type="normalizedLine.type"
:line-code="normalizedLine.lineCode"
:line-position="linePosition"
:line-number="lineNumber"
:meta-data="normalizedLine.metaData"
:show-comment-button="showCommentButton"
:context-lines-path="diffFile.contextLinesPath"
:is-bottom="isBottom"
:is-match-line="isMatchLine"
:is-context-line="isContentLine"
......
......@@ -5,8 +5,8 @@ export default {
type: String,
required: true,
},
currentUser: {
type: Object,
canCurrentUserFork: {
type: Boolean,
required: true,
},
canModifyBlob: {
......@@ -17,12 +17,12 @@ export default {
},
methods: {
handleEditClick(evt) {
if (!this.currentUser || this.canModifyBlob) {
if (!this.canCurrentUserFork || this.canModifyBlob) {
// if we can Edit, do default Edit button behavior
return;
}
if (this.currentUser.canFork && this.currentUser.canCreateMergeRequest) {
if (this.canCurrentUserFork) {
evt.preventDefault();
this.$emit('showForkMessage');
}
......
......@@ -13,12 +13,8 @@ export default {
type: Object,
required: true,
},
diffFile: {
type: Object,
required: true,
},
diffLines: {
type: Array,
diffFileHash: {
type: String,
required: true,
},
lineIndex: {
......@@ -61,10 +57,9 @@ export default {
/>
<diff-line-note-form
v-if="hasCommentForm"
:diff-file="diffFile"
:diff-lines="diffLines"
:diff-file-hash="diffFileHash"
:line="line"
:note-target-line="diffLines[lineIndex]"
:note-target-line="line"
/>
</div>
</td>
......
......@@ -16,8 +16,12 @@ export default {
DiffTableCell,
},
props: {
diffFile: {
type: Object,
fileHash: {
type: String,
required: true,
},
contextLinesPath: {
type: String,
required: true,
},
line: {
......@@ -50,7 +54,7 @@ export default {
inlineRowId() {
const { lineCode, oldLine, newLine } = this.line;
return lineCode || `${this.diffFile.fileHash}_${oldLine}_${newLine}`;
return lineCode || `${this.fileHash}_${oldLine}_${newLine}`;
},
},
created() {
......@@ -78,7 +82,8 @@ export default {
@mouseout="handleMouseMove"
>
<diff-table-cell
:diff-file="diffFile"
:file-hash="fileHash"
:context-lines-path="contextLinesPath"
:line="line"
:line-type="oldLineType"
:is-bottom="isBottom"
......@@ -87,7 +92,8 @@ export default {
class="diff-line-num old_line"
/>
<diff-table-cell
:diff-file="diffFile"
:file-hash="fileHash"
:context-lines-path="contextLinesPath"
:line="line"
:line-type="newLineType"
:is-bottom="isBottom"
......
......@@ -59,15 +59,15 @@ export default {
v-for="(line, index) in normalizedDiffLines"
>
<inline-diff-table-row
:diff-file="diffFile"
:file-hash="diffFile.fileHash"
:context-lines-path="diffFile.contextLinesPath"
:line="line"
:is-bottom="index + 1 === diffLinesLength"
:key="line.lineCode"
/>
<inline-diff-comment-row
v-if="shouldRenderCommentRow(line)"
:diff-file="diffFile"
:diff-lines="normalizedDiffLines"
:diff-file-hash="diffFile.fileHash"
:line="line"
:line-index="index"
:key="index"
......
......@@ -13,12 +13,8 @@ export default {
type: Object,
required: true,
},
diffFile: {
type: Object,
required: true,
},
diffLines: {
type: Array,
diffFileHash: {
type: String,
required: true,
},
lineIndex: {
......@@ -91,10 +87,9 @@ export default {
<diff-line-note-form
v-if="diffLineCommentForms[leftLineCode] &&
diffLineCommentForms[leftLineCode]"
:diff-file="diffFile"
:diff-lines="diffLines"
:diff-file-hash="diffFileHash"
:line="line.left"
:note-target-line="diffLines[lineIndex].left"
:note-target-line="line.left"
position="left"
/>
</td>
......@@ -112,10 +107,9 @@ export default {
<diff-line-note-form
v-if="diffLineCommentForms[rightLineCode] &&
diffLineCommentForms[rightLineCode] && line.right.type"
:diff-file="diffFile"
:diff-lines="diffLines"
:diff-file-hash="diffFileHash"
:line="line.right"
:note-target-line="diffLines[lineIndex].right"
:note-target-line="line.right"
position="right"
/>
</td>
......
......@@ -19,8 +19,12 @@ export default {
DiffTableCell,
},
props: {
diffFile: {
type: Object,
fileHash: {
type: String,
required: true,
},
contextLinesPath: {
type: String,
required: true,
},
line: {
......@@ -103,7 +107,8 @@ export default {
@mouseout="handleMouseMove"
>
<diff-table-cell
:diff-file="diffFile"
:file-hash="fileHash"
:context-lines-path="contextLinesPath"
:line="line"
:line-type="oldLineType"
:line-position="linePositionLeft"
......@@ -123,7 +128,8 @@ export default {
>
</td>
<diff-table-cell
:diff-file="diffFile"
:file-hash="fileHash"
:context-lines-path="contextLinesPath"
:line="line"
:line-type="newLineType"
:line-position="linePositionRight"
......
......@@ -92,17 +92,17 @@ export default {
v-for="(line, index) in parallelDiffLines"
>
<parallel-diff-table-row
:diff-file="diffFile"
:file-hash="diffFile.fileHash"
:context-lines-path="diffFile.contextLinesPath"
:line="line"
:is-bottom="index + 1 === diffLinesLength"
:key="index"
/>
<parallel-diff-comment-row
v-if="shouldRenderCommentRow(line)"
:key="line.left.lineCode || line.right.lineCode"
:key="`dcr-${index}`"
:line="line"
:diff-file="diffFile"
:diff-lines="parallelDiffLines"
:diff-file-hash="diffFile.fileHash"
:line-index="index"
/>
</template>
......
......@@ -97,4 +97,8 @@ export const discussionsByLineCode = (state, getters, rootState, rootGetters) =>
};
// prevent babel-plugin-rewire from generating an invalid default during karma∂ tests
export const getDiffFileByHash = state => fileHash =>
state.diffFiles.find(file => file.fileHash === fileHash);
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};
......@@ -38,6 +38,7 @@ export default {
<button
:aria-label="label"
type="button"
class="btn-blank"
@click.stop.prevent="clicked"
>
<icon
......
import _ from 'underscore';
function sortMetrics(metrics) {
return _.chain(metrics).sortBy('title').sortBy('weight').value();
return _.chain(metrics)
.sortBy('title')
.sortBy('weight')
.value();
}
function normalizeMetrics(metrics) {
......@@ -39,7 +42,9 @@ export default class MonitoringStore {
}
storeEnvironmentsData(environmentsData = []) {
this.environmentsData = environmentsData;
this.environmentsData = environmentsData.filter(
environment => !!environment.latest.last_deployment,
);
}
getMetricsCount() {
......
<script>
import { mapState, mapActions } from 'vuex';
import imageDiffHelper from '~/image_diff/helpers/index';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import DiffFileHeader from '~/diffs/components/diff_file_header.vue';
import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue';
import { trimFirstCharOfLineContent } from '~/diffs/store/utils';
import { mapState, mapActions } from 'vuex';
import imageDiffHelper from '~/image_diff/helpers/index';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import DiffFileHeader from '~/diffs/components/diff_file_header.vue';
import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue';
import { trimFirstCharOfLineContent } from '~/diffs/store/utils';
export default {
export default {
components: {
DiffFileHeader,
SkeletonLoadingContainer,
......@@ -27,8 +27,7 @@
noteableData: state => state.notes.noteableData,
}),
hasTruncatedDiffLines() {
return this.discussion.truncatedDiffLines &&
this.discussion.truncatedDiffLines.length !== 0;
return this.discussion.truncatedDiffLines && this.discussion.truncatedDiffLines.length !== 0;
},
isDiscussionsExpanded() {
return true; // TODO: @fatihacet - Fix this.
......@@ -49,9 +48,6 @@
imageDiffHtml() {
return this.discussion.imageDiffHtml;
},
currentUser() {
return this.noteableData.current_user;
},
userColorScheme() {
return window.gon.user_color_scheme;
},
......@@ -88,7 +84,7 @@
});
},
},
};
};
</script>
<template>
......@@ -99,7 +95,7 @@
>
<diff-file-header
:diff-file="diffFile"
:current-user="currentUser"
:can-current-user-fork="false"
:discussions-expanded="isDiscussionsExpanded"
:expanded="!isCollapsed"
/>
......
......@@ -303,9 +303,11 @@ $flash-height: 52px;
$context-header-height: 60px;
$breadcrumb-min-height: 48px;
// EE-only CSS variables START
$issue-box-upcoming-bg: #8f8f8f;
$pages-group-name-color: #4c4e54;
$ldap-members-override-bg: $orange-50;
// EE-only CSS variables END
/*
* Common component specific colors
......
......@@ -551,6 +551,7 @@
@include media-breakpoint-up(lg) {
.branch-actions {
align-self: center;
margin-left: $gl-padding;
}
}
}
......
......@@ -210,7 +210,7 @@ class Note < ActiveRecord::Base
end
def hook_attrs
attributes
Gitlab::HookData::NoteBuilder.new(self).build
end
def for_commit?
......
......@@ -60,7 +60,7 @@ class WikiPage
attr_accessor :attributes
def hook_attrs
attributes
Gitlab::HookData::WikiPageBuilder.new(self).build
end
def initialize(wiki, page = nil, persisted = false)
......
# frozen_string_literal: true
module ApplicationSettings
class BaseService < ::BaseService
def initialize(application_setting, user, params = {})
......
# frozen_string_literal: true
module ApplicationSettings
class UpdateService < ApplicationSettings::BaseService
prepend EE::ApplicationSettings::UpdateService
......
# frozen_string_literal: true
module Applications
class CreateService
prepend ::EE::Applications::CreateService
......
# frozen_string_literal: true
module Auth
class ContainerRegistryAuthenticationService < BaseService
AUDIENCE = 'container_registry'.freeze
......
# frozen_string_literal: true
module Badges
class BaseService
protected
......
# frozen_string_literal: true
module Badges
class BuildService < Badges::BaseService
# returns the created badge
......
# frozen_string_literal: true
module Badges
class CreateService < Badges::BaseService
# returns the created badge
......
# frozen_string_literal: true
module Badges
class UpdateService < Badges::BaseService
# returns the updated badge
......
# frozen_string_literal: true
module Boards
class BaseService < ::BaseService
prepend EE::Boards::BaseService
......
# frozen_string_literal: true
module Boards
class CreateService < Boards::BaseService
prepend EE::Boards::CreateService
......
# frozen_string_literal: true
module Boards
module Issues
class CreateService < Boards::BaseService
......
# frozen_string_literal: true
module Boards
module Issues
class ListService < Boards::BaseService
......
# frozen_string_literal: true
module Boards
module Issues
class MoveService < Boards::BaseService
......
# frozen_string_literal: true
module Boards
class ListService < Boards::BaseService
prepend EE::Boards::ListService
......
# frozen_string_literal: true
module Boards
module Lists
class CreateService < Boards::BaseService
......
# frozen_string_literal: true
module Boards
module Lists
class DestroyService < Boards::BaseService
......
# frozen_string_literal: true
module Boards
module Lists
class GenerateService < Boards::BaseService
......
# frozen_string_literal: true
module Boards
module Lists
class ListService < Boards::BaseService
......
# frozen_string_literal: true
module Boards
module Lists
class MoveService < Boards::BaseService
......
# frozen_string_literal: true
module ChatNames
class AuthorizeUserService
include Gitlab::Routing
......
# frozen_string_literal: true
module ChatNames
class FindUserService
def initialize(service, params)
......
# frozen_string_literal: true
module Ci
class CreatePipelineScheduleService < BaseService
def execute
......
# frozen_string_literal: true
module Ci
class CreatePipelineService < BaseService
attr_reader :pipeline
......
# frozen_string_literal: true
module Ci
##
# We call this service everytime we persist a CI/CD job.
......
# frozen_string_literal: true
module Ci
class ExtractSectionsFromBuildTraceService < BaseService
def execute(build)
......
# frozen_string_literal: true
##
# TODO:
# Almost components in this class were copied from app/models/project_services/kubernetes_service.rb
......
# frozen_string_literal: true
module Ci
class PipelineTriggerService < BaseService
include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
module Ci
class PlayBuildService < ::BaseService
def execute(build)
......
# frozen_string_literal: true
module Ci
class ProcessPipelineService < BaseService
attr_reader :pipeline
......
# frozen_string_literal: true
module Ci
# This class responsible for assigning
# proper pending build to runner on runner API request
......
# frozen_string_literal: true
module Ci
class RetryBuildService < ::BaseService
CLONE_ACCESSORS = %i[pipeline project ref tag options commands name
......
# frozen_string_literal: true
module Ci
class RetryPipelineService < ::BaseService
include Gitlab::OptimisticLocking
......
# frozen_string_literal: true
module Ci
class StopEnvironmentsService < BaseService
attr_reader :ref
......
# frozen_string_literal: true
module Ci
class UpdateBuildQueueService
def execute(build)
......
# frozen_string_literal: true
module Ci
class UpdateRunnerService
attr_reader :runner
......
# frozen_string_literal: true
module Clusters
module Applications
class BaseHelmService
......
# frozen_string_literal: true
module Clusters
module Applications
class CheckIngressIpAddressService < BaseHelmService
......
# frozen_string_literal: true
module Clusters
module Applications
class CheckInstallationProgressService < BaseHelmService
......
# frozen_string_literal: true
module Clusters
module Applications
class InstallService < BaseHelmService
......
# frozen_string_literal: true
module Clusters
module Applications
class ScheduleInstallationService < ::BaseService
......
# frozen_string_literal: true
module Clusters
class CreateService < BaseService
prepend EE::Clusters::CreateService
......
# frozen_string_literal: true
module Clusters
module Gcp
class FetchOperationService
......
# frozen_string_literal: true
module Clusters
module Gcp
class FinalizeCreationService
......
# frozen_string_literal: true
module Clusters
module Gcp
class ProvisionService
......
# frozen_string_literal: true
module Clusters
module Gcp
class VerifyProvisionStatusService
......
# frozen_string_literal: true
module Clusters
class UpdateService < BaseService
def execute(cluster)
......
# frozen_string_literal: true
module Commits
class ChangeService < Commits::CreateService
def initialize(*args)
......
# frozen_string_literal: true
module Commits
class CherryPickService < ChangeService
def create_commit!
......
# frozen_string_literal: true
module Commits
class CreateService < ::BaseService
prepend EE::Commits::CreateService
......
# frozen_string_literal: true
module Commits
class RevertService < ChangeService
def create_commit!
......
# frozen_string_literal: true
#
# Concern that helps with getting an exclusive lease for running a block
# of code.
......
# frozen_string_literal: true
module Issues
module ResolveDiscussions
include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
module UpdateVisibilityLevel
def valid_visibility_level_change?(target, new_visibility)
# check that user is allowed to set specified visibility_level
......
# frozen_string_literal: true
module Users
module NewUserNotifier
def notify_new_user(user, reset_token)
......
# frozen_string_literal: true
module Users
module ParticipableService
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module DeployKeys
class CreateService < Keys::BaseService
def execute
......
# frozen_string_literal: true
module DeployTokens
class CreateService < BaseService
def execute
......
# frozen_string_literal: true
module Discussions
class BaseService < ::BaseService
end
......
# frozen_string_literal: true
module Discussions
class ResolveService < Discussions::BaseService
def execute(one_or_more_discussions)
......
# frozen_string_literal: true
module Discussions
class UpdateDiffPositionService < BaseService
def execute(discussion)
......
# frozen_string_literal: true
module Emails
class BaseService
def initialize(current_user, params = {})
......
# frozen_string_literal: true
module Emails
class ConfirmService < ::Emails::BaseService
def execute(email)
......
# frozen_string_literal: true
module Emails
class CreateService < ::Emails::BaseService
prepend ::EE::Emails::CreateService
......
# frozen_string_literal: true
module Emails
class DestroyService < ::Emails::BaseService
prepend ::EE::Emails::DestroyService
......
# frozen_string_literal: true
module Events
class RenderService < BaseRenderer
def execute(events, atom_request: false)
......
# frozen_string_literal: true
module Files
class BaseService < Commits::CreateService
FileChangedError = Class.new(StandardError)
......
# frozen_string_literal: true
module Files
class CreateDirService < Files::BaseService
def create_commit!
......
# frozen_string_literal: true
module Files
class CreateService < Files::BaseService
def create_commit!
......
# frozen_string_literal: true
module Files
class DeleteService < Files::BaseService
def create_commit!
......
# frozen_string_literal: true
module Files
class MultiService < Files::BaseService
UPDATE_FILE_ACTIONS = %w(update move delete).freeze
......
# frozen_string_literal: true
module Files
class UpdateService < Files::BaseService
def create_commit!
......
# frozen_string_literal: true
module GpgKeys
class CreateService < Keys::BaseService
def execute
......
# frozen_string_literal: true
module Groups
class BaseService < ::BaseService
attr_accessor :group, :current_user, :params
......
# frozen_string_literal: true
module Groups
class CreateService < Groups::BaseService
prepend ::EE::Groups::CreateService
......
# frozen_string_literal: true
module Groups
class DestroyService < Groups::BaseService
prepend ::EE::Groups::DestroyService
......
# frozen_string_literal: true
module Groups
class NestedCreateService < Groups::BaseService
attr_reader :group_path, :visibility_level
......
# frozen_string_literal: true
module Groups
class TransferService < Groups::BaseService
ERROR_MESSAGES = {
......
# frozen_string_literal: true
module Groups
class UpdateService < Groups::BaseService
include UpdateVisibilityLevel
......
# frozen_string_literal: true
module Issuable
class BulkUpdateService < IssuableBaseService
def execute(type)
......
# frozen_string_literal: true
module Issuable
class CommonSystemNotesService < ::BaseService
prepend EE::Issuable::CommonSystemNotesService
......
# frozen_string_literal: true
module Issuable
class DestroyService < IssuableBaseService
def execute(issuable)
......
# frozen_string_literal: true
module Issues
class BaseService < ::IssuableBaseService
def hook_data(issue, action, old_associations: {})
......
# frozen_string_literal: true
module Issues
class BuildService < Issues::BaseService
include ResolveDiscussions
......@@ -45,14 +47,14 @@ module Issues
other_note_count = discussion.notes.size - 1
discussion_info = "- [ ] #{first_note_to_resolve.author.to_reference} #{action} a [discussion](#{note_url}): "
discussion_info << " (+#{other_note_count} #{'comment'.pluralize(other_note_count)})" if other_note_count > 0
discussion_info = ["- [ ] #{first_note_to_resolve.author.to_reference} #{action} a [discussion](#{note_url}): "]
discussion_info << "(+#{other_note_count} #{'comment'.pluralize(other_note_count)})" if other_note_count > 0
note_without_block_quotes = Banzai::Filter::BlockquoteFenceFilter.new(first_note_to_resolve.note).call
spaces = ' ' * 4
quote = note_without_block_quotes.lines.map { |line| "#{spaces}> #{line}" }.join
[discussion_info, quote].join("\n\n")
[discussion_info.join(' '), quote].join("\n\n")
end
def issue_params
......
# frozen_string_literal: true
module Issues
class CloseService < Issues::BaseService
# Closes the supplied issue if the current user is able to do so.
......
# frozen_string_literal: true
module Issues
class CreateService < Issues::BaseService
include SpamCheckService
......
# frozen_string_literal: true
module Issues
class DuplicateService < Issues::BaseService
def execute(duplicate_issue, canonical_issue)
......
# frozen_string_literal: true
module Issues
class FetchReferencedMergeRequestsService < Issues::BaseService
def execute(issue)
......
# frozen_string_literal: true
module Issues
class MoveService < Issues::BaseService
prepend ::EE::Issues::MoveService
......
# frozen_string_literal: true
module Issues
class ReopenService < Issues::BaseService
def execute(issue)
......
# frozen_string_literal: true
module Issues
class UpdateService < Issues::BaseService
include SpamCheckService
......
# frozen_string_literal: true
module Keys
class BaseService
attr_accessor :user, :params
......
# frozen_string_literal: true
module Keys
class CreateService < ::Keys::BaseService
prepend EE::Keys::CreateService
......
# frozen_string_literal: true
module Keys
class DestroyService < ::Keys::BaseService
prepend EE::Keys::DestroyService
......
# frozen_string_literal: true
module Keys
class LastUsedService
TIMEOUT = 1.day.to_i
......
# frozen_string_literal: true
module Labels
class BaseService < ::BaseService
COLOR_NAME_TO_HEX = {
......
# frozen_string_literal: true
module Labels
class CreateService < Labels::BaseService
def initialize(params = {})
......
# frozen_string_literal: true
module Labels
class FindOrCreateService
def initialize(current_user, parent, params = {})
......
# frozen_string_literal: true
module Labels
class PromoteService < BaseService
BATCH_SIZE = 1000
......
# frozen_string_literal: true
# Labels::TransferService class
#
# User for recreate the missing group labels at project level
......
# frozen_string_literal: true
module Labels
class UpdateService < Labels::BaseService
def initialize(params = {})
......
- link = link_to _("GitLab Runner section"), 'https://about.gitlab.com/gitlab-ci/#gitlab-runner', target: '_blank'
- link = link_to _("Install GitLab Runner"), 'https://docs.gitlab.com/runner/install/', target: '_blank'
.append-bottom-10
%h4= _("Setup a #{type} Runner manually")
%ol
%li
= _("Install a Runner compatible with GitLab CI")
= (_("(check out the %{link} for information on how to install it).") % { link: link }).html_safe
= link.html_safe
%li
= _("Specify the following URL during the Runner setup:")
%code#coordinator_address= root_url(only_path: false)
= clipboard_button(target: '#coordinator_address', title: _("Copy URL to clipboard"), class: "btn-transparent btn-clipboard")
%li
= _("Use the following registration token during setup:")
%code#registration_token= registration_token
= clipboard_button(target: '#registration_token', title: _("Copy token to clipboard"), class: "btn-transparent btn-clipboard")
%li
= _("Start the Runner!")
---
title: Add merge request header branch actions left margin
merge_request: 20643
author: George Tsiolis
type: changed
---
title: Enable frozen string in app/services/**/*.rb
merge_request: 20656
author: gfyoung
type: performance
---
title: Include full image URL in webhooks for uploaded images
merge_request: 18109
author: Satish Perala
type: changed
---
title: Fix symlink vulnerability in project import
merge_request:
author:
type: security
---
title: Update specific runners help URL
merge_request: 20213
author: George Tsiolis
type: other
......@@ -10,6 +10,13 @@ Starting from GitLab 8.5:
Starting from GitLab 11.1, the logs of web hooks are automatically removed after
one month.
>**Note**
Starting from GitLab 11.2:
- The `description` field for issues, merge requests, comments, and wiki pages
is rewritten so that simple Markdown image references (like
`![](/uploads/...)`) have their target URL changed to an absolute URL. See
[image URL rewriting](#image-url-rewriting) for more details.
Project webhooks allow you to trigger a URL if for example new code is pushed or
a new issue is created. You can configure webhooks to listen for specific events
like pushes, issues or merge requests. GitLab will send a POST request with data
......@@ -1150,6 +1157,27 @@ X-Gitlab-Event: Build Hook
}
```
## Image URL rewriting
From GitLab 11.2, simple image references are rewritten to use an absolute URL
in webhooks. So if an image, merge request, comment, or wiki page has this in
its description:
```markdown
![image](/uploads/$sha/image.png)
```
It will appear in the webhook body as the below (assuming that GitLab is
installed at gitlab.example.com):
```markdown
![image](https://gitlab.example.com/uploads/$sha/image.png)
```
This will not rewrite URLs that already are pointing to HTTP, HTTPS, or
protocol-relative URLs. It will also not rewrite image URLs using advanced
Markdown features, like link labels.
## Testing webhooks
You can trigger the webhook manually. Sample data from the project will be used.Sample data will take from the project.
......
......@@ -2,27 +2,7 @@ module Banzai
module Filter
class BlockquoteFenceFilter < HTML::Pipeline::TextFilter
REGEX = %r{
(?<code>
# Code blocks:
# ```
# Anything, including `>>>` blocks which are ignored by this filter
# ```
^```
.+?
\n```\ *$
)
|
(?<html>
# HTML block:
# <tag>
# Anything, including `>>>` blocks which are ignored by this filter
# </tag>
^<[^>]+?>\ *\n
.+?
\n<\/[^>]+?>\ *$
)
#{::Gitlab::Regex.markdown_code_or_html_blocks}
|
(?:
# Blockquote:
......
module Gitlab
module HookData
class BaseBuilder
attr_accessor :object
MARKDOWN_SIMPLE_IMAGE = %r{
#{::Gitlab::Regex.markdown_code_or_html_blocks}
|
(?<image>
!
\[(?<title>[^\n]*?)\]
\((?<url>(?!(https?://|//))[^\n]+?)\)
)
}mx.freeze
def initialize(object)
@object = object
end
private
def absolute_image_urls(markdown_text)
return markdown_text unless markdown_text.present?
markdown_text.gsub(MARKDOWN_SIMPLE_IMAGE) do
if $~[:image]
url = $~[:url]
url = "/#{url}" unless url.start_with?('/')
"![#{$~[:title]}](#{Gitlab.config.gitlab.url}#{url})"
else
$~[0]
end
end
end
end
end
end
module Gitlab
module HookData
class IssuableBuilder
class IssuableBuilder < BaseBuilder
CHANGES_KEYS = %i[previous current].freeze
attr_accessor :issuable
def initialize(issuable)
@issuable = issuable
end
alias_method :issuable, :object
def build(user: nil, changes: {})
hook_data = {
......
module Gitlab
module HookData
class IssueBuilder
class IssueBuilder < BaseBuilder
SAFE_HOOK_ATTRIBUTES = %i[
assignee_id
author_id
......@@ -30,14 +30,11 @@ module Gitlab
total_time_spent
].freeze
attr_accessor :issue
def initialize(issue)
@issue = issue
end
alias_method :issue, :object
def build
attrs = {
description: absolute_image_urls(issue.description),
url: Gitlab::UrlBuilder.build(issue),
total_time_spent: issue.total_time_spent,
human_total_time_spent: issue.human_total_time_spent,
......
module Gitlab
module HookData
class MergeRequestBuilder
class MergeRequestBuilder < BaseBuilder
SAFE_HOOK_ATTRIBUTES = %i[
assignee_id
author_id
......@@ -35,14 +35,11 @@ module Gitlab
total_time_spent
].freeze
attr_accessor :merge_request
def initialize(merge_request)
@merge_request = merge_request
end
alias_method :merge_request, :object
def build
attrs = {
description: absolute_image_urls(merge_request.description),
url: Gitlab::UrlBuilder.build(merge_request),
source: merge_request.source_project.try(:hook_attrs),
target: merge_request.target_project.hook_attrs,
......
module Gitlab
module HookData
class NoteBuilder < BaseBuilder
SAFE_HOOK_ATTRIBUTES = %i[
attachment
author_id
change_position
commit_id
created_at
discussion_id
id
line_code
note
noteable_id
noteable_type
original_position
position
project_id
resolved_at
resolved_by_id
resolved_by_push
st_diff
system
type
updated_at
updated_by_id
].freeze
alias_method :note, :object
def build
note
.attributes
.with_indifferent_access
.slice(*SAFE_HOOK_ATTRIBUTES)
.merge(
description: absolute_image_urls(note.note),
url: Gitlab::UrlBuilder.build(note)
)
end
end
end
end
module Gitlab
module HookData
class WikiPageBuilder < BaseBuilder
alias_method :wiki_page, :object
def build
wiki_page
.attributes
.merge(
'content' => absolute_image_urls(wiki_page.content)
)
end
end
end
end
......@@ -4,6 +4,7 @@ module Gitlab
include Gitlab::ImportExport::CommandLineUtil
MAX_RETRIES = 8
IGNORED_FILENAMES = %w(. ..).freeze
def self.import(*args)
new(*args).import
......@@ -59,7 +60,7 @@ module Gitlab
end
def extracted_files
Dir.glob("#{@shared.export_path}/**/*", File::FNM_DOTMATCH).reject { |f| f =~ %r{.*/\.{1,2}$} }
Dir.glob("#{@shared.export_path}/**/*", File::FNM_DOTMATCH).reject { |f| IGNORED_FILENAMES.include?(File.basename(f)) }
end
end
end
......
......@@ -74,5 +74,31 @@ module Gitlab
def build_trace_section_regex
@build_trace_section_regexp ||= /section_((?:start)|(?:end)):(\d+):([a-zA-Z0-9_.-]+)\r\033\[0K/.freeze
end
def markdown_code_or_html_blocks
@markdown_code_or_html_blocks ||= %r{
(?<code>
# Code blocks:
# ```
# Anything, including `>>>` blocks which are ignored by this filter
# ```
^```
.+?
\n```\ *$
)
|
(?<html>
# HTML block:
# <tag>
# Anything, including `>>>` blocks which are ignored by this filter
# </tag>
^<[^>]+?>\ *\n
.+?
\n<\/[^>]+?>\ *$
)
}mx
end
end
end
......@@ -8,8 +8,6 @@ msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-07-17 07:12+0000\n"
"PO-Revision-Date: 2018-07-17 07:12+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
......@@ -162,9 +160,6 @@ msgstr[1] ""
msgid "%{unstaged} unstaged and %{staged} staged changes"
msgstr ""
msgid "(check out the %{link} for information on how to install it)."
msgstr ""
msgid "+ %{moreCount} more"
msgstr ""
......@@ -2062,6 +2057,9 @@ msgstr ""
msgid "Copy to clipboard"
msgstr ""
msgid "Copy token to clipboard"
msgstr ""
msgid "Create"
msgstr ""
......@@ -3188,9 +3186,6 @@ msgstr ""
msgid "GitLab Import"
msgstr ""
msgid "GitLab Runner section"
msgstr ""
msgid "GitLab User"
msgstr ""
......@@ -3580,10 +3575,10 @@ msgstr ""
msgid "Inline"
msgstr ""
msgid "Install Runner on Kubernetes"
msgid "Install GitLab Runner"
msgstr ""
msgid "Install a Runner compatible with GitLab CI"
msgid "Install Runner on Kubernetes"
msgstr ""
msgid "Instance"
......
......@@ -24,7 +24,7 @@ describe('diff_file_header', () => {
const diffFile = convertObjectPropsToCamelCase(diffDiscussionMock.diff_file, { deep: true });
props = {
diffFile,
currentUser: {},
canCurrentUserFork: false,
};
});
......
......@@ -11,7 +11,7 @@ describe('DiffFile', () => {
beforeEach(() => {
vm = createComponentWithStore(Vue.extend(DiffFileComponent), store, {
file: getDiffFileMock(),
currentUser: {},
canCurrentUserFork: false,
}).$mount();
});
......
......@@ -15,7 +15,7 @@ describe('DiffLineNoteForm', () => {
diffLines = diffFile.highlightedDiffLines;
component = createComponentWithStore(Vue.extend(DiffLineNoteForm), store, {
diffFile,
diffFileHash: diffFile.fileHash,
diffLines,
line: diffLines[0],
noteTargetLine: diffLines[0],
......
......@@ -186,6 +186,25 @@ describe('Diffs Module Getters', () => {
});
});
describe('getDiffFileByHash', () => {
it('returns file by hash', () => {
const fileA = {
fileHash: '123',
};
const fileB = {
fileHash: '456',
};
localState.diffFiles = [fileA, fileB];
expect(getters.getDiffFileByHash(localState)('456')).toEqual(fileB);
});
it('returns null if no matching file is found', () => {
localState.diffFiles = [];
expect(getters.getDiffFileByHash(localState)('123')).toBeUndefined();
});
});
describe('discussionsByLineCode', () => {
let mockState;
......
......@@ -6561,6 +6561,9 @@ export const environmentData = [
folder_path: '/root/hello-prometheus/environments/folders/production',
created_at: '2018-06-29T16:53:38.301Z',
updated_at: '2018-06-29T16:57:09.825Z',
last_deployment: {
id: 127,
},
},
},
{
......@@ -6580,6 +6583,20 @@ export const environmentData = [
folder_path: '/root/hello-prometheus/environments/folders/review',
created_at: '2018-07-03T18:39:41.702Z',
updated_at: '2018-07-03T18:44:54.010Z',
last_deployment: {
id: 128,
},
},
},
{
name: 'no-deployment',
size: 1,
latest: {
id: 36,
name: 'no-deployment/noop-branch',
state: 'available',
created_at: '2018-07-04T18:39:41.702Z',
updated_at: '2018-07-04T18:44:54.010Z',
},
},
];
import MonitoringStore from '~/monitoring/stores/monitoring_store';
import MonitoringMock, { deploymentData } from './mock_data';
import MonitoringMock, { deploymentData, environmentData } from './mock_data';
describe('MonitoringStore', function () {
this.store = new MonitoringStore();
......@@ -21,4 +21,9 @@ describe('MonitoringStore', function () {
expect(this.store.deploymentData.length).toEqual(3);
expect(typeof this.store.deploymentData[0]).toEqual('object');
});
it('only stores environment data that contains deployments', () => {
this.store.storeEnvironmentsData(environmentData);
expect(this.store.environmentsData.length).toEqual(2);
});
});
require 'spec_helper'
describe Gitlab::HookData::BaseBuilder do
describe '#absolute_image_urls' do
let(:subclass) do
Class.new(described_class) do
public :absolute_image_urls
end
end
subject { subclass.new(nil) }
using RSpec::Parameterized::TableSyntax
where do
{
'relative image URL' => {
input: '![an image](foo.png)',
output: "![an image](#{Gitlab.config.gitlab.url}/foo.png)"
},
'HTTP URL' => {
input: '![an image](http://example.com/foo.png)',
output: '![an image](http://example.com/foo.png)'
},
'HTTPS URL' => {
input: '![an image](https://example.com/foo.png)',
output: '![an image](https://example.com/foo.png)'
},
'protocol-relative URL' => {
input: '![an image](//example.com/foo.png)',
output: '![an image](//example.com/foo.png)'
},
'URL reference by title' => {
input: "![foo]\n\n[foo]: foo.png",
output: "![foo]\n\n[foo]: foo.png"
},
'URL reference by label' => {
input: "![][foo]\n\n[foo]: foo.png",
output: "![][foo]\n\n[foo]: foo.png"
},
'in Markdown inline code block' => {
input: '`![an image](foo.png)`',
output: "`![an image](#{Gitlab.config.gitlab.url}/foo.png)`"
},
'in HTML tag on the same line' => {
input: '<p>![an image](foo.png)</p>',
output: "<p>![an image](#{Gitlab.config.gitlab.url}/foo.png)</p>"
},
'in Markdown multi-line code block' => {
input: "```\n![an image](foo.png)\n```",
output: "```\n![an image](foo.png)\n```"
},
'in HTML tag on different lines' => {
input: "<p>\n![an image](foo.png)\n</p>",
output: "<p>\n![an image](foo.png)\n</p>"
}
}
end
with_them do
it { expect(subject.absolute_image_urls(input)).to eq(output) }
end
end
end
......@@ -40,5 +40,14 @@ describe Gitlab::HookData::IssueBuilder do
expect(data).to include(:human_total_time_spent)
expect(data).to include(:assignee_ids)
end
context 'when the issue has an image in the description' do
let(:issue_with_description) { create(:issue, description: 'test![Issue_Image](/uploads/abc/Issue_Image.png)') }
let(:builder) { described_class.new(issue_with_description) }
it 'sets the image to use an absolute URL' do
expect(data[:description]).to eq("test![Issue_Image](#{Settings.gitlab.url}/uploads/abc/Issue_Image.png)")
end
end
end
end
......@@ -56,5 +56,14 @@ describe Gitlab::HookData::MergeRequestBuilder do
expect(data).to include(:human_time_estimate)
expect(data).to include(:human_total_time_spent)
end
context 'when the MR has an image in the description' do
let(:mr_with_description) { create(:merge_request, description: 'test![Issue_Image](/uploads/abc/Issue_Image.png)') }
let(:builder) { described_class.new(mr_with_description) }
it 'sets the image to use an absolute URL' do
expect(data[:description]).to eq("test![Issue_Image](#{Settings.gitlab.url}/uploads/abc/Issue_Image.png)")
end
end
end
end
......@@ -7,6 +7,7 @@ describe Gitlab::ImportExport::FileImporter do
let(:symlink_file) { "#{shared.export_path}/invalid.json" }
let(:hidden_symlink_file) { "#{shared.export_path}/.hidden" }
let(:subfolder_symlink_file) { "#{shared.export_path}/subfolder/invalid.json" }
let(:evil_symlink_file) { "#{shared.export_path}/.\nevil" }
before do
stub_const('Gitlab::ImportExport::FileImporter::MAX_RETRIES', 0)
......@@ -34,6 +35,10 @@ describe Gitlab::ImportExport::FileImporter do
expect(File.exist?(hidden_symlink_file)).to be false
end
it 'removes evil symlinks in root folder' do
expect(File.exist?(evil_symlink_file)).to be false
end
it 'removes symlinks in subfolders' do
expect(File.exist?(subfolder_symlink_file)).to be false
end
......@@ -75,5 +80,7 @@ describe Gitlab::ImportExport::FileImporter do
FileUtils.touch(valid_file)
FileUtils.ln_s(valid_file, symlink_file)
FileUtils.ln_s(valid_file, subfolder_symlink_file)
FileUtils.ln_s(valid_file, hidden_symlink_file)
FileUtils.ln_s(valid_file, evil_symlink_file)
end
end
......@@ -554,6 +554,16 @@ describe WikiPage do
end
end
describe '#hook_attrs' do
it 'adds absolute urls for images in the content' do
create_page("test page", "test![WikiPage_Image](/uploads/abc/WikiPage_Image.png)")
page = wiki.wiki.page(title: "test page")
wiki_page = described_class.new(wiki, page, true)
expect(wiki_page.hook_attrs['content']).to eq("test![WikiPage_Image](#{Settings.gitlab.url}/uploads/abc/WikiPage_Image.png)")
end
end
private
def remove_temp_repo(path)
......
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