Commit 977edf89 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'nt/ce-to-ee-thursday' into 'master'

CE upstream: Thursday

See merge request !1544
parents 494d0f3f ce3459e1
...@@ -278,14 +278,35 @@ rake karma: ...@@ -278,14 +278,35 @@ rake karma:
paths: paths:
- coverage-javascript/ - coverage-javascript/
lint-doc: docs:check:apilint:
image: "phusion/baseimage"
stage: test stage: test
<<: *dedicated-runner <<: *dedicated-runner
image: "phusion/baseimage:latest" variables:
GIT_DEPTH: "3"
cache: {}
dependencies: []
before_script: [] before_script: []
script: script:
- scripts/lint-doc.sh - scripts/lint-doc.sh
docs:check:links:
image: "registry.gitlab.com/gitlab-org/gitlab-build-images:nanoc-bootstrap-ruby-2.4-alpine"
stage: test
<<: *dedicated-runner
variables:
GIT_DEPTH: "3"
cache: {}
dependencies: []
before_script: []
script:
- mv doc/ /nanoc/content/
- cd /nanoc
# Build HTML from Markdown
- bundle exec nanoc
# Check the internal links
- bundle exec nanoc check internal_links
bundler:check: bundler:check:
stage: test stage: test
<<: *dedicated-runner <<: *dedicated-runner
......
...@@ -33,12 +33,11 @@ export default Vue.component('pipelines-table', { ...@@ -33,12 +33,11 @@ export default Vue.component('pipelines-table', {
* @return {Object} * @return {Object}
*/ */
data() { data() {
const pipelinesTableData = document.querySelector('#commit-pipeline-table-view').dataset;
const store = new PipelineStore(); const store = new PipelineStore();
return { return {
endpoint: pipelinesTableData.endpoint, endpoint: null,
helpPagePath: pipelinesTableData.helpPagePath, helpPagePath: null,
store, store,
state: store.state, state: store.state,
isLoading: false, isLoading: false,
...@@ -65,6 +64,8 @@ export default Vue.component('pipelines-table', { ...@@ -65,6 +64,8 @@ export default Vue.component('pipelines-table', {
* *
*/ */
beforeMount() { beforeMount() {
this.endpoint = this.$el.dataset.endpoint;
this.helpPagePath = this.$el.dataset.helpPagePath;
this.service = new PipelinesService(this.endpoint); this.service = new PipelinesService(this.endpoint);
this.fetchPipelines(); this.fetchPipelines();
......
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var */ /* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var */
$(document).on('todo:toggle', function(e, count) { $(document).on('todo:toggle', function(e, count) {
var $todoPendingCount = $('.todos-pending-count'); var $todoPendingCount = $('.todos-count');
$todoPendingCount.text(gl.text.highCountTrim(count)); $todoPendingCount.text(gl.text.highCountTrim(count));
$todoPendingCount.toggleClass('hidden', count === 0); $todoPendingCount.toggleClass('hidden', count === 0);
}); });
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
require('./breakpoints'); import CommitPipelinesTable from './commit/pipelines/pipelines_table';
require('./flash');
import './breakpoints';
import './flash';
/* eslint-disable max-len */ /* eslint-disable max-len */
// MergeRequestTabs // MergeRequestTabs
...@@ -97,6 +99,13 @@ require('./flash'); ...@@ -97,6 +99,13 @@ require('./flash');
.off('click', this.clickTab); .off('click', this.clickTab);
} }
destroy() {
this.unbindEvents();
if (this.commitPipelinesTable) {
this.commitPipelinesTable.$destroy();
}
}
showTab(e) { showTab(e) {
e.preventDefault(); e.preventDefault();
this.activateTab($(e.target).data('action')); this.activateTab($(e.target).data('action'));
...@@ -128,12 +137,8 @@ require('./flash'); ...@@ -128,12 +137,8 @@ require('./flash');
this.expandViewContainer(); this.expandViewContainer();
} }
} else if (action === 'pipelines') { } else if (action === 'pipelines') {
if (this.pipelinesLoaded) { this.resetViewContainer();
return; this.loadPipelines();
}
const pipelineTableViewEl = document.querySelector('#commit-pipeline-table-view');
gl.commits.pipelines.PipelinesTableBundle.$mount(pipelineTableViewEl);
this.pipelinesLoaded = true;
} else { } else {
this.expandView(); this.expandView();
this.resetViewContainer(); this.resetViewContainer();
...@@ -222,6 +227,18 @@ require('./flash'); ...@@ -222,6 +227,18 @@ require('./flash');
}); });
} }
loadPipelines() {
if (this.pipelinesLoaded) {
return;
}
const pipelineTableViewEl = document.querySelector('#commit-pipeline-table-view');
// Could already be mounted from the `pipelines_bundle`
if (pipelineTableViewEl) {
this.commitPipelinesTable = new CommitPipelinesTable().$mount(pipelineTableViewEl);
}
this.pipelinesLoaded = true;
}
loadDiff(source) { loadDiff(source) {
if (this.diffsLoaded) { if (this.diffsLoaded) {
return; return;
......
...@@ -56,14 +56,15 @@ import Cookies from 'js-cookie'; ...@@ -56,14 +56,15 @@ import Cookies from 'js-cookie';
Sidebar.prototype.toggleTodo = function(e) { Sidebar.prototype.toggleTodo = function(e) {
var $btnText, $this, $todoLoading, ajaxType, url; var $btnText, $this, $todoLoading, ajaxType, url;
$this = $(e.currentTarget); $this = $(e.currentTarget);
$todoLoading = $('.js-issuable-todo-loading');
$btnText = $('.js-issuable-todo-text', $this);
ajaxType = $this.attr('data-delete-path') ? 'DELETE' : 'POST'; ajaxType = $this.attr('data-delete-path') ? 'DELETE' : 'POST';
if ($this.attr('data-delete-path')) { if ($this.attr('data-delete-path')) {
url = "" + ($this.attr('data-delete-path')); url = "" + ($this.attr('data-delete-path'));
} else { } else {
url = "" + ($this.data('url')); url = "" + ($this.data('url'));
} }
$this.tooltip('hide');
return $.ajax({ return $.ajax({
url: url, url: url,
type: ajaxType, type: ajaxType,
...@@ -74,34 +75,44 @@ import Cookies from 'js-cookie'; ...@@ -74,34 +75,44 @@ import Cookies from 'js-cookie';
}, },
beforeSend: (function(_this) { beforeSend: (function(_this) {
return function() { return function() {
return _this.beforeTodoSend($this, $todoLoading); $('.js-issuable-todo').disable()
.addClass('is-loading');
}; };
})(this) })(this)
}).done((function(_this) { }).done((function(_this) {
return function(data) { return function(data) {
return _this.todoUpdateDone(data, $this, $btnText, $todoLoading); return _this.todoUpdateDone(data);
}; };
})(this)); })(this));
}; };
Sidebar.prototype.beforeTodoSend = function($btn, $todoLoading) { Sidebar.prototype.todoUpdateDone = function(data) {
$btn.disable(); const deletePath = data.delete_path ? data.delete_path : null;
return $todoLoading.removeClass('hidden'); const attrPrefix = deletePath ? 'mark' : 'todo';
}; const $todoBtns = $('.js-issuable-todo');
Sidebar.prototype.todoUpdateDone = function(data, $btn, $btnText, $todoLoading) {
$(document).trigger('todo:toggle', data.count); $(document).trigger('todo:toggle', data.count);
$btn.enable(); $todoBtns.each((i, el) => {
$todoLoading.addClass('hidden'); const $el = $(el);
const $elText = $el.find('.js-issuable-todo-inner');
if (data.delete_path != null) { $el.removeClass('is-loading')
$btn.attr('aria-label', $btn.data('mark-text')).attr('data-delete-path', data.delete_path); .enable()
return $btnText.text($btn.data('mark-text')); .attr('aria-label', $el.data(`${attrPrefix}-text`))
} else { .attr('data-delete-path', deletePath)
$btn.attr('aria-label', $btn.data('todo-text')).removeAttr('data-delete-path'); .attr('title', $el.data(`${attrPrefix}-text`));
return $btnText.text($btn.data('todo-text'));
} if ($el.hasClass('has-tooltip')) {
$el.tooltip('fixTitle');
}
if ($el.data(`${attrPrefix}-icon`)) {
$elText.html($el.data(`${attrPrefix}-icon`));
} else {
$elText.text($el.data(`${attrPrefix}-text`));
}
});
}; };
Sidebar.prototype.sidebarDropdownLoading = function(e) { Sidebar.prototype.sidebarDropdownLoading = function(e) {
......
...@@ -362,3 +362,13 @@ ...@@ -362,3 +362,13 @@
width: 100%; width: 100%;
} }
} }
.btn-blank {
padding: 0;
background: transparent;
border: 0;
&:focus {
outline: 0;
}
}
...@@ -48,10 +48,10 @@ header { ...@@ -48,10 +48,10 @@ header {
color: $gl-text-color-secondary; color: $gl-text-color-secondary;
font-size: 18px; font-size: 18px;
padding: 0; padding: 0;
margin: ($header-height - 28) / 2 0; margin: (($header-height - 28) / 2) 3px;
margin-left: 8px; margin-left: 8px;
height: 28px; height: 28px;
min-width: 28px; min-width: 32px;
line-height: 28px; line-height: 28px;
text-align: center; text-align: center;
...@@ -73,21 +73,29 @@ header { ...@@ -73,21 +73,29 @@ header {
background-color: $gray-light; background-color: $gray-light;
color: $gl-text-color; color: $gl-text-color;
.todos-pending-count { svg {
background: darken($todo-alert-blue, 10%); fill: $gl-text-color;
} }
} }
.fa-caret-down { .fa-caret-down {
font-size: 14px; font-size: 14px;
} }
svg {
position: relative;
top: 2px;
height: 17px;
// hack to get SVG to line up with FA icons
width: 23px;
fill: $gl-text-color-secondary;
}
} }
.navbar-toggle { .navbar-toggle {
color: $nav-toggle-gray; color: $nav-toggle-gray;
margin: 7px 0; margin: 5px 0;
border-radius: 0; border-radius: 0;
position: absolute;
right: -10px; right: -10px;
padding: 6px 10px; padding: 6px 10px;
...@@ -141,10 +149,6 @@ header { ...@@ -141,10 +149,6 @@ header {
min-height: $header-height; min-height: $header-height;
padding-left: 30px; padding-left: 30px;
@media (max-width: $screen-sm-max) {
padding-right: 20px;
}
.dropdown-menu { .dropdown-menu {
margin-top: -5px; margin-top: -5px;
} }
...@@ -243,10 +247,7 @@ header { ...@@ -243,10 +247,7 @@ header {
.navbar-collapse { .navbar-collapse {
flex: 0 0 auto; flex: 0 0 auto;
border-top: none; border-top: none;
padding: 0;
@media (min-width: $screen-md-min) {
padding: 0;
}
@media (max-width: $screen-xs-max) { @media (max-width: $screen-xs-max) {
flex: 1 1 auto; flex: 1 1 auto;
...@@ -263,6 +264,34 @@ header { ...@@ -263,6 +264,34 @@ header {
} }
} }
.navbar-nav {
li {
.badge {
position: inherit;
top: -3px;
font-weight: normal;
margin-left: -12px;
font-size: 11px;
color: $white-light;
padding: 1px 5px 2px;
border-radius: 7px;
box-shadow: 0 1px 0 rgba($gl-header-color, .2);
&.issues-count {
background-color: $green-500;
}
&.merge-requests-count {
background-color: $orange-600;
}
&.todos-count {
background-color: $blue-500;
}
}
}
}
@media (max-width: $screen-xs-max) { @media (max-width: $screen-xs-max) {
header .container-fluid { header .container-fluid {
font-size: 18px; font-size: 18px;
......
...@@ -52,6 +52,18 @@ ...@@ -52,6 +52,18 @@
} }
} }
@mixin basic-list-stats {
.stats {
float: right;
line-height: $list-text-height;
color: $gl-text-color;
span {
margin-right: 15px;
}
}
}
@mixin bulleted-list { @mixin bulleted-list {
> ul { > ul {
list-style-type: disc; list-style-type: disc;
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
padding-right: 0; padding-right: 0;
@media (min-width: $screen-sm-min) { @media (min-width: $screen-sm-min) {
.content-wrapper { &:not(.wiki-sidebar):not(.build-sidebar) .content-wrapper {
padding-right: $gutter_collapsed_width; padding-right: $gutter_collapsed_width;
} }
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
padding-right: 0; padding-right: 0;
@media (min-width: $screen-sm-min) and (max-width: $screen-sm-max) { @media (min-width: $screen-sm-min) and (max-width: $screen-sm-max) {
.content-wrapper { &:not(.wiki-sidebar):not(.build-sidebar) .content-wrapper {
padding-right: $gutter_collapsed_width; padding-right: $gutter_collapsed_width;
} }
} }
......
...@@ -22,15 +22,7 @@ ...@@ -22,15 +22,7 @@
} }
.group-row { .group-row {
.stats { @include basic-list-stats;
float: right;
line-height: $list-text-height;
color: $gl-text-color;
span {
margin-right: 15px;
}
}
} }
.ldap-group-links { .ldap-group-links {
......
...@@ -243,6 +243,10 @@ ...@@ -243,6 +243,10 @@
font-size: 13px; font-size: 13px;
font-weight: normal; font-weight: normal;
} }
.hide-expanded {
display: none;
}
} }
&.right-sidebar-collapsed { &.right-sidebar-collapsed {
...@@ -282,10 +286,11 @@ ...@@ -282,10 +286,11 @@
display: block; display: block;
width: 100%; width: 100%;
text-align: center; text-align: center;
padding-bottom: 10px; margin-bottom: 10px;
color: $issuable-sidebar-color; color: $issuable-sidebar-color;
&:hover { &:hover,
&:hover .todo-undone {
color: $gl-text-color; color: $gl-text-color;
} }
...@@ -294,6 +299,10 @@ ...@@ -294,6 +299,10 @@
margin-top: 0; margin-top: 0;
} }
.todo-undone {
color: $gl-link-color;
}
.author { .author {
display: none; display: none;
} }
...@@ -582,3 +591,21 @@ ...@@ -582,3 +591,21 @@
opacity: 0; opacity: 0;
} }
} }
.issuable-todo-btn {
.fa-spinner {
display: none;
}
&.is-loading {
.fa-spinner {
display: inline-block;
}
&.sidebar-collapsed-icon {
.issuable-todo-inner {
display: none;
}
}
}
}
...@@ -573,9 +573,19 @@ pre.light-well { ...@@ -573,9 +573,19 @@ pre.light-well {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
// Disable Flexbox for admin page
&.admin-projects {
display: block;
.project-row {
display: block;
}
}
.project-row { .project-row {
display: flex; display: flex;
align-items: center; align-items: center;
@include basic-list-stats;
} }
h3 { h3 {
......
...@@ -3,25 +3,6 @@ ...@@ -3,25 +3,6 @@
* *
*/ */
.navbar-nav {
li {
.badge.todos-pending-count {
position: inherit;
top: -6px;
margin-top: -5px;
font-weight: normal;
background: $todo-alert-blue;
margin-left: -17px;
font-size: 11px;
color: $white-light;
padding: 3px;
padding-top: 1px;
padding-bottom: 1px;
border-radius: 3px;
}
}
}
.todos-list > .todo { .todos-list > .todo {
// workaround because we cannot use border-colapse // workaround because we cannot use border-colapse
border-top: 1px solid transparent; border-top: 1px solid transparent;
......
class Admin::BackgroundJobsController < Admin::ApplicationController class Admin::BackgroundJobsController < Admin::ApplicationController
def show def show
ps_output, _ = Gitlab::Popen.popen(%W(ps -U #{Gitlab.config.gitlab.user} -o pid,pcpu,pmem,stat,start,command)) ps_output, _ = Gitlab::Popen.popen(%W(ps ww -U #{Gitlab.config.gitlab.user} -o pid,pcpu,pmem,stat,start,command))
@sidekiq_processes = ps_output.split("\n").grep(/sidekiq/) @sidekiq_processes = ps_output.split("\n").grep(/sidekiq/)
@concurrency = Sidekiq.options[:concurrency] @concurrency = Sidekiq.options[:concurrency]
end end
......
...@@ -16,10 +16,9 @@ class Admin::LabelsController < Admin::ApplicationController ...@@ -16,10 +16,9 @@ class Admin::LabelsController < Admin::ApplicationController
end end
def create def create
@label = Label.new(label_params) @label = Labels::CreateService.new(label_params).execute(template: true)
@label.template = true
if @label.save if @label.persisted?
redirect_to admin_labels_url, notice: "Label was created" redirect_to admin_labels_url, notice: "Label was created"
else else
render :new render :new
...@@ -27,7 +26,9 @@ class Admin::LabelsController < Admin::ApplicationController ...@@ -27,7 +26,9 @@ class Admin::LabelsController < Admin::ApplicationController
end end
def update def update
if @label.update(label_params) @label = Labels::UpdateService.new(label_params).execute(@label)
if @label.valid?
redirect_to admin_labels_path, notice: 'label was successfully updated.' redirect_to admin_labels_path, notice: 'label was successfully updated.'
else else
render :edit render :edit
......
...@@ -26,7 +26,7 @@ class Groups::LabelsController < Groups::ApplicationController ...@@ -26,7 +26,7 @@ class Groups::LabelsController < Groups::ApplicationController
end end
def create def create
@label = @group.labels.create(label_params) @label = Labels::CreateService.new(label_params).execute(group: group)
if @label.valid? if @label.valid?
redirect_to group_labels_path(@group) redirect_to group_labels_path(@group)
...@@ -40,7 +40,9 @@ class Groups::LabelsController < Groups::ApplicationController ...@@ -40,7 +40,9 @@ class Groups::LabelsController < Groups::ApplicationController
end end
def update def update
if @label.update_attributes(label_params) @label = Labels::UpdateService.new(label_params).execute(@label)
if @label.valid?
redirect_back_or_group_labels_path redirect_back_or_group_labels_path
else else
render :edit render :edit
......
...@@ -29,7 +29,7 @@ class Projects::LabelsController < Projects::ApplicationController ...@@ -29,7 +29,7 @@ class Projects::LabelsController < Projects::ApplicationController
end end
def create def create
@label = @project.labels.create(label_params) @label = Labels::CreateService.new(label_params).execute(project: @project)
if @label.valid? if @label.valid?
respond_to do |format| respond_to do |format|
...@@ -48,7 +48,9 @@ class Projects::LabelsController < Projects::ApplicationController ...@@ -48,7 +48,9 @@ class Projects::LabelsController < Projects::ApplicationController
end end
def update def update
if @label.update_attributes(label_params) @label = Labels::UpdateService.new(label_params).execute(@label)
if @label.valid?
redirect_to namespace_project_labels_path(@project.namespace, @project) redirect_to namespace_project_labels_path(@project.namespace, @project)
else else
render :edit render :edit
......
class GroupFinder
include Gitlab::Allowable
def initialize(current_user)
@current_user = current_user
end
def execute(*params)
group = Group.find_by(*params)
if can?(@current_user, :read_group, group)
group
else
nil
end
end
end
...@@ -257,4 +257,19 @@ module IssuablesHelper ...@@ -257,4 +257,19 @@ module IssuablesHelper
def selected_template(issuable) def selected_template(issuable)
params[:issuable_template] if issuable_templates(issuable).include?(params[:issuable_template]) params[:issuable_template] if issuable_templates(issuable).include?(params[:issuable_template])
end end
def issuable_todo_button_data(issuable, todo, is_collapsed)
{
todo_text: "Add todo",
mark_text: "Mark done",
todo_icon: (is_collapsed ? icon('plus-square') : nil),
mark_icon: (is_collapsed ? icon('check-square', class: 'todo-undone') : nil),
issuable_id: issuable.id,
issuable_type: issuable.class.name.underscore,
url: namespace_project_todos_path(@project.namespace, @project),
delete_path: (dashboard_todo_path(todo) if todo),
placement: (is_collapsed ? 'left' : nil),
container: (is_collapsed ? 'body' : nil)
}
end
end end
...@@ -105,6 +105,10 @@ class CommitStatus < ActiveRecord::Base ...@@ -105,6 +105,10 @@ class CommitStatus < ActiveRecord::Base
end end
end end
def locking_enabled?
status_changed?
end
def before_sha def before_sha
pipeline.before_sha || Gitlab::Git::BLANK_SHA pipeline.before_sha || Gitlab::Git::BLANK_SHA
end end
......
...@@ -121,10 +121,10 @@ class Namespace < ActiveRecord::Base ...@@ -121,10 +121,10 @@ class Namespace < ActiveRecord::Base
# Move the namespace directory in all storages paths used by member projects # Move the namespace directory in all storages paths used by member projects
repository_storage_paths.each do |repository_storage_path| repository_storage_paths.each do |repository_storage_path|
# Ensure old directory exists before moving it # Ensure old directory exists before moving it
gitlab_shell.add_namespace(repository_storage_path, path_was) gitlab_shell.add_namespace(repository_storage_path, full_path_was)
unless gitlab_shell.mv_namespace(repository_storage_path, path_was, path) unless gitlab_shell.mv_namespace(repository_storage_path, full_path_was, full_path)
Rails.logger.error "Exception moving path #{repository_storage_path} from #{path_was} to #{path}" Rails.logger.error "Exception moving path #{repository_storage_path} from #{full_path_was} to #{full_path}"
# if we cannot move namespace directory we should rollback # if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs # db changes in order to prevent out of sync between db and fs
...@@ -132,8 +132,8 @@ class Namespace < ActiveRecord::Base ...@@ -132,8 +132,8 @@ class Namespace < ActiveRecord::Base
end end
end end
Gitlab::UploadsTransfer.new.rename_namespace(path_was, path) Gitlab::UploadsTransfer.new.rename_namespace(full_path_was, full_path)
Gitlab::PagesTransfer.new.rename_namespace(path_was, path) Gitlab::PagesTransfer.new.rename_namespace(full_path_was, full_path)
remove_exports! remove_exports!
...@@ -156,7 +156,7 @@ class Namespace < ActiveRecord::Base ...@@ -156,7 +156,7 @@ class Namespace < ActiveRecord::Base
def send_update_instructions def send_update_instructions
projects.each do |project| projects.each do |project|
project.send_move_instructions("#{path_was}/#{project.path}") project.send_move_instructions("#{full_path_was}/#{project.path}")
end end
end end
...@@ -235,10 +235,10 @@ class Namespace < ActiveRecord::Base ...@@ -235,10 +235,10 @@ class Namespace < ActiveRecord::Base
old_repository_storage_paths.each do |repository_storage_path| old_repository_storage_paths.each do |repository_storage_path|
# Move namespace directory into trash. # Move namespace directory into trash.
# We will remove it later async # We will remove it later async
new_path = "#{path}+#{id}+deleted" new_path = "#{full_path}+#{id}+deleted"
if gitlab_shell.mv_namespace(repository_storage_path, path, new_path) if gitlab_shell.mv_namespace(repository_storage_path, full_path, new_path)
message = "Namespace directory \"#{path}\" moved to \"#{new_path}\"" message = "Namespace directory \"#{full_path}\" moved to \"#{new_path}\""
Gitlab::AppLogger.info message Gitlab::AppLogger.info message
# Remove namespace directroy async with delay so # Remove namespace directroy async with delay so
......
module Groups module Groups
class UpdateService < Groups::BaseService class UpdateService < Groups::BaseService
def execute def execute
reject_parent_id!
# check that user is allowed to set specified visibility_level # check that user is allowed to set specified visibility_level
new_visibility = params[:visibility_level] new_visibility = params[:visibility_level]
if new_visibility && new_visibility.to_i != group.visibility_level if new_visibility && new_visibility.to_i != group.visibility_level
...@@ -26,5 +28,11 @@ module Groups ...@@ -26,5 +28,11 @@ module Groups
false false
end end
end end
private
def reject_parent_id!
params.except!(:parent_id)
end
end end
end end
module Labels
class BaseService < ::BaseService
COLOR_NAME_TO_HEX = {
black: '#000000',
silver: '#C0C0C0',
gray: '#808080',
white: '#FFFFFF',
maroon: '#800000',
red: '#FF0000',
purple: '#800080',
fuchsia: '#FF00FF',
green: '#008000',
lime: '#00FF00',
olive: '#808000',
yellow: '#FFFF00',
navy: '#000080',
blue: '#0000FF',
teal: '#008080',
aqua: '#00FFFF',
orange: '#FFA500',
aliceblue: '#F0F8FF',
antiquewhite: '#FAEBD7',
aquamarine: '#7FFFD4',
azure: '#F0FFFF',
beige: '#F5F5DC',
bisque: '#FFE4C4',
blanchedalmond: '#FFEBCD',
blueviolet: '#8A2BE2',
brown: '#A52A2A',
burlywood: '#DEB887',
cadetblue: '#5F9EA0',
chartreuse: '#7FFF00',
chocolate: '#D2691E',
coral: '#FF7F50',
cornflowerblue: '#6495ED',
cornsilk: '#FFF8DC',
crimson: '#DC143C',
darkblue: '#00008B',
darkcyan: '#008B8B',
darkgoldenrod: '#B8860B',
darkgray: '#A9A9A9',
darkgreen: '#006400',
darkgrey: '#A9A9A9',
darkkhaki: '#BDB76B',
darkmagenta: '#8B008B',
darkolivegreen: '#556B2F',
darkorange: '#FF8C00',
darkorchid: '#9932CC',
darkred: '#8B0000',
darksalmon: '#E9967A',
darkseagreen: '#8FBC8F',
darkslateblue: '#483D8B',
darkslategray: '#2F4F4F',
darkslategrey: '#2F4F4F',
darkturquoise: '#00CED1',
darkviolet: '#9400D3',
deeppink: '#FF1493',
deepskyblue: '#00BFFF',
dimgray: '#696969',
dimgrey: '#696969',
dodgerblue: '#1E90FF',
firebrick: '#B22222',
floralwhite: '#FFFAF0',
forestgreen: '#228B22',
gainsboro: '#DCDCDC',
ghostwhite: '#F8F8FF',
gold: '#FFD700',
goldenrod: '#DAA520',
greenyellow: '#ADFF2F',
grey: '#808080',
honeydew: '#F0FFF0',
hotpink: '#FF69B4',
indianred: '#CD5C5C',
indigo: '#4B0082',
ivory: '#FFFFF0',
khaki: '#F0E68C',
lavender: '#E6E6FA',
lavenderblush: '#FFF0F5',
lawngreen: '#7CFC00',
lemonchiffon: '#FFFACD',
lightblue: '#ADD8E6',
lightcoral: '#F08080',
lightcyan: '#E0FFFF',
lightgoldenrodyellow: '#FAFAD2',
lightgray: '#D3D3D3',
lightgreen: '#90EE90',
lightgrey: '#D3D3D3',
lightpink: '#FFB6C1',
lightsalmon: '#FFA07A',
lightseagreen: '#20B2AA',
lightskyblue: '#87CEFA',
lightslategray: '#778899',
lightslategrey: '#778899',
lightsteelblue: '#B0C4DE',
lightyellow: '#FFFFE0',
limegreen: '#32CD32',
linen: '#FAF0E6',
mediumaquamarine: '#66CDAA',
mediumblue: '#0000CD',
mediumorchid: '#BA55D3',
mediumpurple: '#9370DB',
mediumseagreen: '#3CB371',
mediumslateblue: '#7B68EE',
mediumspringgreen: '#00FA9A',
mediumturquoise: '#48D1CC',
mediumvioletred: '#C71585',
midnightblue: '#191970',
mintcream: '#F5FFFA',
mistyrose: '#FFE4E1',
moccasin: '#FFE4B5',
navajowhite: '#FFDEAD',
oldlace: '#FDF5E6',
olivedrab: '#6B8E23',
orangered: '#FF4500',
orchid: '#DA70D6',
palegoldenrod: '#EEE8AA',
palegreen: '#98FB98',
paleturquoise: '#AFEEEE',
palevioletred: '#DB7093',
papayawhip: '#FFEFD5',
peachpuff: '#FFDAB9',
peru: '#CD853F',
pink: '#FFC0CB',
plum: '#DDA0DD',
powderblue: '#B0E0E6',
rosybrown: '#BC8F8F',
royalblue: '#4169E1',
saddlebrown: '#8B4513',
salmon: '#FA8072',
sandybrown: '#F4A460',
seagreen: '#2E8B57',
seashell: '#FFF5EE',
sienna: '#A0522D',
skyblue: '#87CEEB',
slateblue: '#6A5ACD',
slategray: '#708090',
slategrey: '#708090',
snow: '#FFFAFA',
springgreen: '#00FF7F',
steelblue: '#4682B4',
tan: '#D2B48C',
thistle: '#D8BFD8',
tomato: '#FF6347',
turquoise: '#40E0D0',
violet: '#EE82EE',
wheat: '#F5DEB3',
whitesmoke: '#F5F5F5',
yellowgreen: '#9ACD32',
rebeccapurple: '#663399'
}.freeze
def convert_color_name_to_hex
color = params[:color]
color_name = color.strip.downcase
return color if color_name.start_with?('#')
COLOR_NAME_TO_HEX[color_name.to_sym] || color
end
end
end
module Labels
class CreateService < Labels::BaseService
def initialize(params = {})
@params = params.dup.with_indifferent_access
end
# returns the created label
def execute(target_params)
params[:color] = convert_color_name_to_hex if params[:color].present?
project_or_group = target_params[:project] || target_params[:group]
if project_or_group.present?
project_or_group.labels.create(params)
elsif target_params[:template]
label = Label.new(params)
label.template = true
label.save
label
else
Rails.logger.warn("target_params should contain :project or :group or :template, actual value: #{target_params}")
end
end
end
end
...@@ -3,7 +3,7 @@ module Labels ...@@ -3,7 +3,7 @@ module Labels
def initialize(current_user, project, params = {}) def initialize(current_user, project, params = {})
@current_user = current_user @current_user = current_user
@project = project @project = project
@params = params.dup @params = params.dup.with_indifferent_access
end end
def execute(skip_authorization: false) def execute(skip_authorization: false)
...@@ -28,7 +28,7 @@ module Labels ...@@ -28,7 +28,7 @@ module Labels
new_label = available_labels.find_by(title: title) new_label = available_labels.find_by(title: title)
if new_label.nil? && (skip_authorization || Ability.allowed?(current_user, :admin_label, project)) if new_label.nil? && (skip_authorization || Ability.allowed?(current_user, :admin_label, project))
new_label = project.labels.create(params) new_label = Labels::CreateService.new(params).execute(project: project)
end end
new_label new_label
......
module Labels
class UpdateService < Labels::BaseService
def initialize(params = {})
@params = params.dup.with_indifferent_access
end
# returns the updated label
def execute(label)
params[:color] = convert_color_name_to_hex if params[:color].present?
label.update(params)
label
end
end
end
.js-projects-list-holder .js-projects-list-holder
- if @projects.any? - if @projects.any?
%ul.projects-list.content-list %ul.projects-list.content-list.admin-projects
- @projects.each_with_index do |project| - @projects.each_with_index do |project|
%li.project-row %li.project-row{ class: ('no-description' if project.description.blank?) }
.controls .controls
- if project.archived
%span.label.label-warning archived
%span.badge
= storage_counter(project.statistics.storage_size)
= link_to 'Edit', edit_namespace_project_path(project.namespace, project), id: "edit_#{dom_id(project)}", class: "btn" = link_to 'Edit', edit_namespace_project_path(project.namespace, project), id: "edit_#{dom_id(project)}", class: "btn"
= link_to 'Delete', [project.namespace.becomes(Namespace), project], data: { confirm: remove_project_message(project) }, method: :delete, class: "btn btn-remove" = link_to 'Delete', [project.namespace.becomes(Namespace), project], data: { confirm: remove_project_message(project) }, method: :delete, class: "btn btn-remove"
.stats
%span.badge
= storage_counter(project.statistics.storage_size)
- if project.archived
%span.label.label-warning archived
.title .title
= link_to [:admin, project.namespace.becomes(Namespace), project] do = link_to [:admin, project.namespace.becomes(Namespace), project] do
.dash-project-avatar .dash-project-avatar
...@@ -20,7 +21,7 @@ ...@@ -20,7 +21,7 @@
- if project.namespace - if project.namespace
= project.namespace.human_name = project.namespace.human_name
\/ \/
%span.project-name.filter-title %span.project-name
= project.name = project.name
- if project.description.present? - if project.description.present?
......
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
= render 'layouts/nav/dashboard' = render 'layouts/nav/dashboard'
- else - else
= render 'layouts/nav/explore' = render 'layouts/nav/explore'
%button.navbar-toggle{ type: 'button' }
%span.sr-only Toggle navigation
= icon('ellipsis-v')
.header-logo .header-logo
= link_to root_path, class: 'home', title: 'Dashboard', id: 'logo' do = link_to root_path, class: 'home', title: 'Dashboard', id: 'logo' do
...@@ -38,10 +35,20 @@ ...@@ -38,10 +35,20 @@
%li %li
= link_to admin_root_path, title: 'Admin Area', aria: { label: "Admin Area" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = link_to admin_root_path, title: 'Admin Area', aria: { label: "Admin Area" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('wrench fw') = icon('wrench fw')
%li
= link_to assigned_issues_dashboard_path, title: 'Issues', aria: { label: "Issues" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('hashtag fw')
%span.badge.issues-count
= number_with_delimiter(cached_assigned_issuables_count(current_user, :issues, :opened))
%li
= link_to assigned_mrs_dashboard_path, title: 'Merge requests', aria: { label: "Merge requests" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= custom_icon('mr_bold')
%span.badge.merge-requests-count
= number_with_delimiter(cached_assigned_issuables_count(current_user, :merge_requests, :opened))
%li %li
= link_to dashboard_todos_path, title: 'Todos', aria: { label: "Todos" }, class: 'shortcuts-todos', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = link_to dashboard_todos_path, title: 'Todos', aria: { label: "Todos" }, class: 'shortcuts-todos', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('bell fw') = icon('check-circle fw')
%span.badge.todos-pending-count{ class: ("hidden" if todos_pending_count == 0) } %span.badge.todos-count
= todos_count_format(todos_pending_count) = todos_count_format(todos_pending_count)
- if current_user.can_create_project? - if current_user.can_create_project?
%li %li
...@@ -76,6 +83,10 @@ ...@@ -76,6 +83,10 @@
%div %div
= link_to "Sign in", new_session_path(:user, redirect_to_referer: 'yes'), class: 'btn btn-sign-in btn-success' = link_to "Sign in", new_session_path(:user, redirect_to_referer: 'yes'), class: 'btn btn-sign-in btn-success'
%button.navbar-toggle{ type: 'button' }
%span.sr-only Toggle navigation
= icon('ellipsis-v')
= yield :header_content = yield :header_content
= render 'shared/outdated_browser' = render 'shared/outdated_browser'
......
...@@ -73,12 +73,12 @@ ...@@ -73,12 +73,12 @@
%span.badge %span.badge
= @search_results.milestones_count = @search_results.milestones_count
- if current_application_settings.elasticsearch_search? - if current_application_settings.elasticsearch_search?
%li{ class: ("active" if @scope == 'blobs') } %li{ class: active_when(@scope == 'blobs') }
= link_to search_filter_path(scope: 'blobs') do = link_to search_filter_path(scope: 'blobs') do
Code Code
%span.badge %span.badge
= @search_results.blobs_count = @search_results.blobs_count
%li{ class: ("active" if @scope == 'commits') } %li{ class: active_when(@scope == 'commits') }
= link_to search_filter_path(scope: 'commits') do = link_to search_filter_path(scope: 'commits') do
Commits Commits
%span.badge %span.badge
......
- parent = Group.find_by(id: params[:parent_id] || @group.parent_id) - parent = GroupFinder.new(current_user).execute(id: params[:parent_id] || @group.parent_id)
- group_path = root_url - group_path = root_url
- group_path << parent.full_path + '/' if parent - group_path << parent.full_path + '/' if parent
- if @group.persisted? - if @group.persisted?
......
<svg width="15" height="20" viewBox="0 0 12 14" xmlns="http://www.w3.org/2000/svg"><path d="M1 4.967a2.15 2.15 0 1 1 2.3 0v5.066a2.15 2.15 0 1 1-2.3 0V4.967zm7.85 5.17V5.496c0-.745-.603-1.346-1.35-1.346V6l-3-3 3-3v1.85c2.016 0 3.65 1.63 3.65 3.646v4.45a2.15 2.15 0 1 1-2.3.191z" fill-rule="nonzero"/></svg>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
%button.btn.btn-link %button.btn.btn-link
= icon('search') = icon('search')
%span %span
Keep typing and press Enter Press Enter or click to search
%ul.filter-dropdown{ data: { dynamic: true, dropdown: true } } %ul.filter-dropdown{ data: { dynamic: true, dropdown: true } }
%li.filter-dropdown-item %li.filter-dropdown-item
%button.btn.btn-link %button.btn.btn-link
......
...@@ -13,15 +13,12 @@ ...@@ -13,15 +13,12 @@
%a.gutter-toggle.pull-right.js-sidebar-toggle{ role: "button", href: "#", "aria-label" => "Toggle sidebar" } %a.gutter-toggle.pull-right.js-sidebar-toggle{ role: "button", href: "#", "aria-label" => "Toggle sidebar" }
= sidebar_gutter_toggle_icon = sidebar_gutter_toggle_icon
- if current_user - if current_user
%button.btn.btn-default.issuable-header-btn.pull-right.js-issuable-todo{ type: "button", "aria-label" => (todo.nil? ? "Add todo" : "Mark done"), data: { todo_text: "Add todo", mark_text: "Mark done", issuable_id: issuable.id, issuable_type: issuable.class.name.underscore, url: namespace_project_todos_path(@project.namespace, @project), delete_path: (dashboard_todo_path(todo) if todo) } } = render "shared/issuable/sidebar_todo", todo: todo, issuable: issuable
%span.js-issuable-todo-text
- if todo
Mark done
- else
Add todo
= icon('spin spinner', class: 'hidden js-issuable-todo-loading', 'aria-hidden': 'true')
= form_for [@project.namespace.becomes(Namespace), @project, issuable], remote: true, format: :json, html: { class: 'issuable-context-form inline-update js-issuable-update' } do |f| = form_for [@project.namespace.becomes(Namespace), @project, issuable], remote: true, format: :json, html: { class: 'issuable-context-form inline-update js-issuable-update' } do |f|
- if current_user
.block.todo.hide-expanded
= render "shared/issuable/sidebar_todo", todo: todo, issuable: issuable, is_collapsed: true
.block.assignee .block.assignee
.sidebar-collapsed-icon.sidebar-collapsed-user{ data: { toggle: "tooltip", placement: "left", container: "body" }, title: (issuable.assignee.name if issuable.assignee) } .sidebar-collapsed-icon.sidebar-collapsed-user{ data: { toggle: "tooltip", placement: "left", container: "body" }, title: (issuable.assignee.name if issuable.assignee) }
- if issuable.assignee - if issuable.assignee
......
- is_collapsed = local_assigns.fetch(:is_collapsed, false)
- mark_content = is_collapsed ? icon('check-square', class: 'todo-undone') : 'Mark done'
- todo_content = is_collapsed ? icon('plus-square') : 'Add todo'
%button.issuable-todo-btn.js-issuable-todo{ type: 'button',
class: (is_collapsed ? 'btn-blank sidebar-collapsed-icon dont-change-state has-tooltip' : 'btn btn-default issuable-header-btn pull-right'),
title: (todo.nil? ? 'Add todo' : 'Mark done'),
'aria-label' => (todo.nil? ? 'Add todo' : 'Mark done'),
data: issuable_todo_button_data(issuable, todo, is_collapsed) }
%span.issuable-todo-inner.js-issuable-todo-inner<
- if todo
= mark_content
- else
= todo_content
= icon('spin spinner', 'aria-hidden': 'true')
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
- if project.namespace && !skip_namespace - if project.namespace && !skip_namespace
= project.namespace.human_name = project.namespace.human_name
\/ \/
%span.project-name.filter-title %span.project-name
= project.name = project.name
- if show_last_commit_as_description - if show_last_commit_as_description
......
...@@ -4,20 +4,16 @@ class PostReceive ...@@ -4,20 +4,16 @@ class PostReceive
extend Gitlab::CurrentSettings extend Gitlab::CurrentSettings
def perform(repo_path, identifier, changes) def perform(repo_path, identifier, changes)
if repository_storage = Gitlab.config.repositories.storages.find { |p| repo_path.start_with?(p[1]['path'].to_s) } repo_relative_path = Gitlab::RepoPath.strip_storage_path(repo_path)
repo_path.gsub!(repository_storage[1]['path'].to_s, "")
else
log("Check gitlab.yml config for correct repositories.storages values. No repository storage path matches \"#{repo_path}\"")
end
changes = Base64.decode64(changes) unless changes.include?(' ') changes = Base64.decode64(changes) unless changes.include?(' ')
# Use Sidekiq.logger so arguments can be correlated with execution # Use Sidekiq.logger so arguments can be correlated with execution
# time and thread ID's. # time and thread ID's.
Sidekiq.logger.info "changes: #{changes.inspect}" if ENV['SIDEKIQ_LOG_ARGUMENTS'] Sidekiq.logger.info "changes: #{changes.inspect}" if ENV['SIDEKIQ_LOG_ARGUMENTS']
post_received = Gitlab::GitPostReceive.new(repo_path, identifier, changes) post_received = Gitlab::GitPostReceive.new(repo_relative_path, identifier, changes)
if post_received.project.nil? if post_received.project.nil?
log("Triggered hook for non-existing project with full path \"#{repo_path}\"") log("Triggered hook for non-existing project with full path \"#{repo_relative_path}\"")
return false return false
end end
...@@ -41,7 +37,7 @@ class PostReceive ...@@ -41,7 +37,7 @@ class PostReceive
process_project_changes(post_received) process_project_changes(post_received)
else else
log("Triggered hook for unidentifiable repository type with full path \"#{repo_path}\"") log("Triggered hook for unidentifiable repository type with full path \"#{repo_relative_path}\"")
false false
end end
end end
......
---
title: Fix API group/issues default state filter
merge_request:
author: Alexander Randa
--- ---
title: Add metadata to system notes title: Add metadata to system notes
merge_request: 1526 merge_request: 9964
author: author:
---
title: Labels support color names in backend
merge_request: 9725
author: Dongqing Hu
---
title: Change hint on first row of filters dropdown to `Press Enter or click to search`
merge_request: 10138
author:
---
title: fix sidebar padding for build and wiki pages
merge_request:
author:
---
title: Correctly update paths when changing a child group
merge_request:
author:
---
title: Add shortcuts and counters to MRs and issues in navbar
merge_request:
author:
---
title: adds todo functionality to closed issuable sidebar and changes todo bell icon
to check-square
merge_request:
author:
---
title: Fix layout of projects page on admin area
merge_request:
author:
---
title: Force unlimited terminal size when checking processes via call to ps
merge_request: 10246
author: Sebastian Reitenbach
---
title: Fixed private group name disclosure via new/update forms
merge_request:
author:
---
title: Make CI build to use optimistic locking only on status change
merge_request:
author:
...@@ -530,14 +530,10 @@ production: &base ...@@ -530,14 +530,10 @@ production: &base
# Gitaly settings # Gitaly settings
gitaly: gitaly:
# The socket_path setting is optional and obsolete. When this is set # This setting controls whether GitLab uses Gitaly (new component
# GitLab assumes it can reach a Gitaly services via a Unix socket at # introduced in 9.0). Eventually Gitaly use will become mandatory and
# this path. When this is commented out GitLab will not use Gitaly. # this option will disappear.
# enabled: false
# This setting is obsolete because we expect it to be moved under
# repositories/storages in GitLab 9.1.
#
# socket_path: tmp/sockets/private/gitaly.socket
# #
# 4. Advanced settings # 4. Advanced settings
...@@ -552,6 +548,7 @@ production: &base ...@@ -552,6 +548,7 @@ production: &base
storages: # You must have at least a `default` storage path. storages: # You must have at least a `default` storage path.
default: default:
path: /home/git/repositories/ path: /home/git/repositories/
gitaly_address: unix:/home/git/gitlab/tmp/sockets/private/gitaly.socket
## Backup settings ## Backup settings
backup: backup:
...@@ -660,10 +657,15 @@ test: ...@@ -660,10 +657,15 @@ test:
# In order to setup it correctly you need to specify # In order to setup it correctly you need to specify
# your system username you use to run GitLab # your system username you use to run GitLab
# user: YOUR_USERNAME # user: YOUR_USERNAME
pages:
path: tmp/tests/pages
repositories: repositories:
storages: storages:
default: default:
path: tmp/tests/repositories/ path: tmp/tests/repositories/
gitaly_address: unix:<%= Rails.root.join('tmp/sockets/private/gitaly.socket') %>
gitaly:
enabled: false
backup: backup:
path: tmp/tests/backups path: tmp/tests/backups
gitlab_shell: gitlab_shell:
......
...@@ -105,6 +105,10 @@ class Settings < Settingslogic ...@@ -105,6 +105,10 @@ class Settings < Settingslogic
value value
end end
def absolute(path)
File.expand_path(path, Rails.root)
end
private private
def base_url(config) def base_url(config)
...@@ -220,7 +224,7 @@ if github_settings ...@@ -220,7 +224,7 @@ if github_settings
end end
Settings['shared'] ||= Settingslogic.new({}) Settings['shared'] ||= Settingslogic.new({})
Settings.shared['path'] = File.expand_path(Settings.shared['path'] || "shared", Rails.root) Settings.shared['path'] = Settings.absolute(Settings.shared['path'] || "shared")
Settings['issues_tracker'] ||= {} Settings['issues_tracker'] ||= {}
...@@ -286,7 +290,7 @@ Settings['gitlab_ci'] ||= Settingslogic.new({}) ...@@ -286,7 +290,7 @@ Settings['gitlab_ci'] ||= Settingslogic.new({})
Settings.gitlab_ci['shared_runners_enabled'] = true if Settings.gitlab_ci['shared_runners_enabled'].nil? Settings.gitlab_ci['shared_runners_enabled'] = true if Settings.gitlab_ci['shared_runners_enabled'].nil?
Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil? Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil?
Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil? Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil?
Settings.gitlab_ci['builds_path'] = File.expand_path(Settings.gitlab_ci['builds_path'] || "builds/", Rails.root) Settings.gitlab_ci['builds_path'] = Settings.absolute(Settings.gitlab_ci['builds_path'] || "builds/")
Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url) Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url)
# #
...@@ -300,7 +304,7 @@ Settings.incoming_email['enabled'] = false if Settings.incoming_email['enabled'] ...@@ -300,7 +304,7 @@ Settings.incoming_email['enabled'] = false if Settings.incoming_email['enabled']
# #
Settings['artifacts'] ||= Settingslogic.new({}) Settings['artifacts'] ||= Settingslogic.new({})
Settings.artifacts['enabled'] = true if Settings.artifacts['enabled'].nil? Settings.artifacts['enabled'] = true if Settings.artifacts['enabled'].nil?
Settings.artifacts['path'] = File.expand_path(Settings.artifacts['path'] || File.join(Settings.shared['path'], "artifacts"), Rails.root) Settings.artifacts['path'] = Settings.absolute(Settings.artifacts['path'] || File.join(Settings.shared['path'], "artifacts"))
Settings.artifacts['max_size'] ||= 100 # in megabytes Settings.artifacts['max_size'] ||= 100 # in megabytes
# #
...@@ -314,14 +318,14 @@ Settings.registry['api_url'] ||= "http://localhost:5000/" ...@@ -314,14 +318,14 @@ Settings.registry['api_url'] ||= "http://localhost:5000/"
Settings.registry['key'] ||= nil Settings.registry['key'] ||= nil
Settings.registry['issuer'] ||= nil Settings.registry['issuer'] ||= nil
Settings.registry['host_port'] ||= [Settings.registry['host'], Settings.registry['port']].compact.join(':') Settings.registry['host_port'] ||= [Settings.registry['host'], Settings.registry['port']].compact.join(':')
Settings.registry['path'] = File.expand_path(Settings.registry['path'] || File.join(Settings.shared['path'], 'registry'), Rails.root) Settings.registry['path'] = Settings.absolute(Settings.registry['path'] || File.join(Settings.shared['path'], 'registry'))
# #
# Pages # Pages
# #
Settings['pages'] ||= Settingslogic.new({}) Settings['pages'] ||= Settingslogic.new({})
Settings.pages['enabled'] = false if Settings.pages['enabled'].nil? Settings.pages['enabled'] = false if Settings.pages['enabled'].nil?
Settings.pages['path'] = File.expand_path(Settings.pages['path'] || File.join(Settings.shared['path'], "pages"), Rails.root) Settings.pages['path'] = Settings.absolute(Settings.pages['path'] || File.join(Settings.shared['path'], "pages"))
Settings.pages['https'] = false if Settings.pages['https'].nil? Settings.pages['https'] = false if Settings.pages['https'].nil?
Settings.pages['host'] ||= "example.com" Settings.pages['host'] ||= "example.com"
Settings.pages['port'] ||= Settings.pages.https ? 443 : 80 Settings.pages['port'] ||= Settings.pages.https ? 443 : 80
...@@ -340,7 +344,7 @@ Settings.gitlab['geo_status_timeout'] ||= 10 ...@@ -340,7 +344,7 @@ Settings.gitlab['geo_status_timeout'] ||= 10
# #
Settings['lfs'] ||= Settingslogic.new({}) Settings['lfs'] ||= Settingslogic.new({})
Settings.lfs['enabled'] = true if Settings.lfs['enabled'].nil? Settings.lfs['enabled'] = true if Settings.lfs['enabled'].nil?
Settings.lfs['storage_path'] = File.expand_path(Settings.lfs['storage_path'] || File.join(Settings.shared['path'], "lfs-objects"), Rails.root) Settings.lfs['storage_path'] = Settings.absolute(Settings.lfs['storage_path'] || File.join(Settings.shared['path'], "lfs-objects"))
# #
# Mattermost # Mattermost
...@@ -429,8 +433,8 @@ Settings.cron_jobs['clear_shared_runners_minutes_worker']['job_class'] = 'ClearS ...@@ -429,8 +433,8 @@ Settings.cron_jobs['clear_shared_runners_minutes_worker']['job_class'] = 'ClearS
# GitLab Shell # GitLab Shell
# #
Settings['gitlab_shell'] ||= Settingslogic.new({}) Settings['gitlab_shell'] ||= Settingslogic.new({})
Settings.gitlab_shell['path'] ||= Settings.gitlab['user_home'] + '/gitlab-shell/' Settings.gitlab_shell['path'] = Settings.absolute(Settings.gitlab_shell['path'] || Settings.gitlab['user_home'] + '/gitlab-shell/')
Settings.gitlab_shell['hooks_path'] ||= Settings.gitlab['user_home'] + '/gitlab-shell/hooks/' Settings.gitlab_shell['hooks_path'] = Settings.absolute(Settings.gitlab_shell['hooks_path'] || Settings.gitlab['user_home'] + '/gitlab-shell/hooks/')
Settings.gitlab_shell['secret_file'] ||= Rails.root.join('.gitlab_shell_secret') Settings.gitlab_shell['secret_file'] ||= Rails.root.join('.gitlab_shell_secret')
Settings.gitlab_shell['receive_pack'] = true if Settings.gitlab_shell['receive_pack'].nil? Settings.gitlab_shell['receive_pack'] = true if Settings.gitlab_shell['receive_pack'].nil?
Settings.gitlab_shell['upload_pack'] = true if Settings.gitlab_shell['upload_pack'].nil? Settings.gitlab_shell['upload_pack'] = true if Settings.gitlab_shell['upload_pack'].nil?
...@@ -453,6 +457,11 @@ unless Settings.repositories.storages['default'] ...@@ -453,6 +457,11 @@ unless Settings.repositories.storages['default']
Settings.repositories.storages['default']['path'] ||= Settings.gitlab['user_home'] + '/repositories/' Settings.repositories.storages['default']['path'] ||= Settings.gitlab['user_home'] + '/repositories/'
end end
Settings.repositories.storages.values.each do |storage|
# Expand relative paths
storage['path'] = Settings.absolute(storage['path'])
end
# #
# The repository_downloads_path is used to remove outdated repository # The repository_downloads_path is used to remove outdated repository
# archives, if someone has it configured incorrectly, and it points # archives, if someone has it configured incorrectly, and it points
...@@ -474,7 +483,7 @@ end ...@@ -474,7 +483,7 @@ end
Settings['backup'] ||= Settingslogic.new({}) Settings['backup'] ||= Settingslogic.new({})
Settings.backup['keep_time'] ||= 0 Settings.backup['keep_time'] ||= 0
Settings.backup['pg_schema'] = nil Settings.backup['pg_schema'] = nil
Settings.backup['path'] = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root) Settings.backup['path'] = Settings.absolute(Settings.backup['path'] || "tmp/backups/")
Settings.backup['archive_permissions'] ||= 0600 Settings.backup['archive_permissions'] ||= 0600
Settings.backup['upload'] ||= Settingslogic.new({ 'remote_directory' => nil, 'connection' => nil }) Settings.backup['upload'] ||= Settingslogic.new({ 'remote_directory' => nil, 'connection' => nil })
# Convert upload connection settings to use symbol keys, to make Fog happy # Convert upload connection settings to use symbol keys, to make Fog happy
...@@ -497,7 +506,7 @@ Settings.git['timeout'] ||= 10 ...@@ -497,7 +506,7 @@ Settings.git['timeout'] ||= 10
# least. This setting is fed to 'rm -rf' in # least. This setting is fed to 'rm -rf' in
# db/migrate/20151023144219_remove_satellites.rb # db/migrate/20151023144219_remove_satellites.rb
Settings['satellites'] ||= Settingslogic.new({}) Settings['satellites'] ||= Settingslogic.new({})
Settings.satellites['path'] = File.expand_path(Settings.satellites['path'] || "tmp/repo_satellites/", Rails.root) Settings.satellites['path'] = Settings.absolute(Settings.satellites['path'] || "tmp/repo_satellites/")
# #
# Kerberos # Kerberos
...@@ -534,7 +543,7 @@ Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour ...@@ -534,7 +543,7 @@ Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour
# Gitaly # Gitaly
# #
Settings['gitaly'] ||= Settingslogic.new({}) Settings['gitaly'] ||= Settingslogic.new({})
Settings.gitaly['socket_path'] ||= ENV['GITALY_SOCKET_PATH'] Settings.gitaly['enabled'] ||= false
# #
# Webpack settings # Webpack settings
......
# Make sure we initialize a Gitaly channel before Sidekiq starts multi-threaded execution. require 'uri'
Gitlab::GitalyClient.channel unless Rails.env.test?
# Make sure we initialize our Gitaly channels before Sidekiq starts multi-threaded execution.
if Gitlab.config.gitaly.enabled || Rails.env.test?
Gitlab.config.repositories.storages.each do |name, params|
address = params['gitaly_address']
unless address.present?
raise "storage #{name.inspect} is missing a gitaly_address"
end
unless URI(address).scheme == 'unix'
raise "Unsupported Gitaly address: #{address.inspect}"
end
Gitlab::GitalyClient.configure_channel(name, address)
end
end
# GitLab Enterprise Edition documentation # GitLab Enterprise Edition
## University All technical content published by GitLab lives in the documentation, including:
[University](university/README.md) contain guides to learn Git and GitLab through courses and videos. - **General Documentation**
- [User docs](#user-documentation): general documentation dedicated to regular users of GitLab
- [Admin docs](#administrator-documentation): general documentation dedicated to administrators of GitLab instances
- [Contributor docs](#contributor-documentation): general documentation on how to develop and contribute to GitLab
- [Topics](topics/index.md): pages organized per topic, gathering all the
resources already published by GitLab related to a specific subject, including
general docs, [technical articles](development/writing_documentation.md#technical-articles),
blog posts and video tutorials.
- [GitLab University](university/README.md): guides to learn Git and GitLab
through courses and videos.
## User documentation ## User documentation
......
...@@ -13,8 +13,8 @@ Database Service (RDS) that runs PostgreSQL. ...@@ -13,8 +13,8 @@ Database Service (RDS) that runs PostgreSQL.
If you use a cloud-managed service, or provide your own PostgreSQL: If you use a cloud-managed service, or provide your own PostgreSQL:
1. Setup PostgreSQL according to the 1. Setup PostgreSQL according to the
[database requirements document](doc/install/requirements.md#database). [database requirements document](../../install/requirements.md#database).
1. Set up a `gitlab` username with a password of your choice. The `gitlab` user 1. Set up a `gitlab` username with a password of your choice. The `gitlab` user
needs privileges to create the `gitlabhq_production` database. needs privileges to create the `gitlabhq_production` database.
1. Configure the GitLab application servers with the appropriate details. 1. Configure the GitLab application servers with the appropriate details.
......
...@@ -90,7 +90,7 @@ POST /projects/:id/labels ...@@ -90,7 +90,7 @@ POST /projects/:id/labels
| ------------- | ------- | -------- | ---------------------------- | | ------------- | ------- | -------- | ---------------------------- |
| `id` | integer | yes | The ID of the project | | `id` | integer | yes | The ID of the project |
| `name` | string | yes | The name of the label | | `name` | string | yes | The name of the label |
| `color` | string | yes | The color of the label in 6-digit hex notation with leading `#` sign | | `color` | string | yes | The color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the [CSS color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords) |
| `description` | string | no | The description of the label | | `description` | string | no | The description of the label |
| `priority` | integer | no | The priority of the label. Must be greater or equal than zero or `null` to remove the priority. | | `priority` | integer | no | The priority of the label. Must be greater or equal than zero or `null` to remove the priority. |
...@@ -145,7 +145,7 @@ PUT /projects/:id/labels ...@@ -145,7 +145,7 @@ PUT /projects/:id/labels
| `id` | integer | yes | The ID of the project | | `id` | integer | yes | The ID of the project |
| `name` | string | yes | The name of the existing label | | `name` | string | yes | The name of the existing label |
| `new_name` | string | yes if `color` is not provided | The new name of the label | | `new_name` | string | yes if `color` is not provided | The new name of the label |
| `color` | string | yes if `new_name` is not provided | The new color of the label in 6-digit hex notation with leading `#` sign | | `color` | string | yes if `new_name` is not provided | The color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the [CSS color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords) |
| `description` | string | no | The new description of the label | | `description` | string | no | The new description of the label |
| `priority` | integer | no | The new priority of the label. Must be greater or equal than zero or `null` to remove the priority. | | `priority` | integer | no | The new priority of the label. Must be greater or equal than zero or `null` to remove the priority. |
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
contributing to the API. contributing to the API.
- [Documentation styleguide](doc_styleguide.md) Use this styleguide if you are - [Documentation styleguide](doc_styleguide.md) Use this styleguide if you are
contributing to documentation. contributing to documentation.
- [Writing documentation](writing_documentation.md)
- [Distinction between general documentation and technical articles](writing_documentation.md#distinction-between-general-documentation-and-technical-articles)
- [SQL Migration Style Guide](migration_style_guide.md) for creating safe SQL migrations - [SQL Migration Style Guide](migration_style_guide.md) for creating safe SQL migrations
- [Testing standards and style guidelines](testing.md) - [Testing standards and style guidelines](testing.md)
- [UX guide](ux_guide/index.md) for building GitLab with existing CSS styles and elements - [UX guide](ux_guide/index.md) for building GitLab with existing CSS styles and elements
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
This styleguide recommends best practices to improve documentation and to keep This styleguide recommends best practices to improve documentation and to keep
it organized and easy to find. it organized and easy to find.
See also [writing documentation](writing_documentation.md).
## Location and naming of documents ## Location and naming of documents
>**Note:** >**Note:**
...@@ -27,6 +29,7 @@ The table below shows what kind of documentation goes where. ...@@ -27,6 +29,7 @@ The table below shows what kind of documentation goes where.
| `doc/legal/` | Legal documents about contributing to GitLab. | | `doc/legal/` | Legal documents about contributing to GitLab. |
| `doc/install/`| Probably the most visited directory, since `installation.md` is there. Ideally this should go under `doc/administration/`, but it's best to leave it as-is in order to avoid confusion (still debated though). | | `doc/install/`| Probably the most visited directory, since `installation.md` is there. Ideally this should go under `doc/administration/`, but it's best to leave it as-is in order to avoid confusion (still debated though). |
| `doc/update/` | Same with `doc/install/`. Should be under `administration/`, but this is a well known location, better leave as-is, at least for now. | | `doc/update/` | Same with `doc/install/`. Should be under `administration/`, but this is a well known location, better leave as-is, at least for now. |
| `doc/topics/` | Indexes per Topic (`doc/topics/topic-name/index.md`); Technical Articles: user guides, admin guides, technical overviews, tutorials (`doc/topics/topic-name/`). |
--- ---
...@@ -56,6 +59,10 @@ The table below shows what kind of documentation goes where. ...@@ -56,6 +59,10 @@ The table below shows what kind of documentation goes where.
own document located at `doc/user/admin_area/settings/`. For example, own document located at `doc/user/admin_area/settings/`. For example,
the **Visibility and Access Controls** category should have a document the **Visibility and Access Controls** category should have a document
located at `doc/user/admin_area/settings/visibility_and_access_controls.md`. located at `doc/user/admin_area/settings/visibility_and_access_controls.md`.
1. The `doc/topics/` directory holds topic-related technical content. Create
`doc/topics/topic-name/subtopic-name/index.md` when subtopics become necessary.
Note that `topics` holds the index page per topic, and technical articles. General
user- and admin- related documentation, should be placed accordingly.
--- ---
......
...@@ -7,7 +7,7 @@ feature tests with Capybara for integration testing. ...@@ -7,7 +7,7 @@ feature tests with Capybara for integration testing.
Feature tests need to be written for all new features. Regression tests ought Feature tests need to be written for all new features. Regression tests ought
to be written for all bug fixes to prevent them from recurring in the future. to be written for all bug fixes to prevent them from recurring in the future.
See [the Testing Standards and Style Guidelines](/doc/development/testing.md) See [the Testing Standards and Style Guidelines](../testing.md)
for more information on general testing practices at GitLab. for more information on general testing practices at GitLab.
## Karma test suite ## Karma test suite
...@@ -48,7 +48,7 @@ remove these directives when you commit your code. ...@@ -48,7 +48,7 @@ remove these directives when you commit your code.
Information on setting up and running RSpec integration tests with Information on setting up and running RSpec integration tests with
[Capybara][capybara] can be found in the [Capybara][capybara] can be found in the
[general testing guide](/doc/development/testing.md). [general testing guide](../testing.md).
## Gotchas ## Gotchas
......
# Writing documentation
- **General Documentation**: written by the developers responsible by creating features. Should be submitted in the same merge request containing code. Feature proposals (by GitLab contributors) should also be accompanied by its respective documentation. They can be later improved by PMs and Technical Writers.
- **Technical Articles**: written by any [GitLab Team](https://about.gitlab.com/team/) member, GitLab contributors, or [Community Writers](https://about.gitlab.com/handbook/product/technical-writing/community-writers/).
- **Indexes per topic**: initially prepared by the Technical Writing Team, and kept up-to-date by developers and PMs, in the same merge request containing code.
## Distinction between General Documentation and Technical Articles
### General documentation
General documentation is categorized by _User_, _Admin_, and _Contributor_, and describe what that feature is, what it does, and its available settings.
### Technical Articles
Technical articles replace technical content that once lived in the [GitLab Blog](https://about.gitlab.com/blog/), where they got out-of-date and weren't easily found.
They are topic-related documentation, written with an user-friendly approach and language, aiming to provide the community with guidance on specific processes to achieve certain objectives.
A technical article guides users and/or admins to achieve certain objectives (within guides and tutorials), or provide an overview of that particular topic or feature (within technical overviews). It can also describe the use, implementation, or integration of third-party tools with GitLab.
They live under `doc/topics/topic-name/`, and can be searched per topic, within "Indexes per Topic" pages. The topics are listed on the main [Indexes per Topic](../topics/index.md) page.
#### Types of Technical Articles
- **User guides**: technical content to guide regular users from point A to point B
- **Admin guides**: technical content to guide administrators of GitLab instances from point A to point B
- **Technical Overviews**: technical content describing features, solutions, and third-party integrations
- **Tutorials**: technical content provided step-by-step on how to do things, or how to reach very specific objectives
#### Understanding guides, tutorials, and technical overviews
Suppose there's a process to go from point A to point B in 5 steps: `(A) 1 > 2 > 3 > 4 > 5 (B)`.
A **guide** can be understood as a description of certain processes to achieve a particular objective. A guide brings you from A to B describing the characteristics of that process, but not necessarily going over each step. It can mention, for example, steps 2 and 3, but does not necessarily explain how to accomplish them.
- Live example: "GitLab Pages from A to Z - [Part 1](../user/project/pages/getting_started_part_one.md) to [Part 4](../user/project/pages/getting_started_part_four.md)"
A **tutorial** requires a clear **step-by-step** guidance to achieve a singular objective. It brings you from A to B, describing precisely all the necessary steps involved in that process, showing each of the 5 steps to go from A to B.
It does not only describes steps 2 and 3, but also shows you how to accomplish them.
- Live example (on the blog): [Hosting on GitLab.com with GitLab Pages](https://about.gitlab.com/2016/04/07/gitlab-pages-setup/)
A **technical overview** is a description of what a certain feature is, and what it does, but does not walk
through the process of how to use it systematically.
- Live example (on the blog): [GitLab Workflow, an overview](https://about.gitlab.com/2016/10/25/gitlab-workflow-an-overview/)
#### Special format
Every **Technical Article** contains, in the very beginning, a blockquote with the following information:
- A reference to the **type of article** (user guide, admin guide, tech overview, tutorial)
- A reference to the **knowledge level** expected from the reader to be able to follow through (beginner, intermediate, advanced)
- A reference to the **author's name** and **GitLab.com handle**
```md
> **Type:** tutorial ||
> **Level:** intermediary ||
> **Author:** [Name Surname](https://gitlab.com/username)
```
#### Technical Articles - Writing Method
Use the [writing method](https://about.gitlab.com/handbook/product/technical-writing/#writing-method) defined by the Technical Writing team.
## Documentation style guidelines
All the docs follow the same [styleguide](doc_styleguide.md).
### Markdown
Currently GitLab docs use Redcarpet as [markdown](../user/markdown.md) engine, but there's an [open discussion](https://gitlab.com/gitlab-com/gitlab-docs/issues/50) for implementing Kramdown in the near future.
...@@ -477,12 +477,12 @@ with setting up Gitaly until you upgrade to GitLab 9.1 or later. ...@@ -477,12 +477,12 @@ with setting up Gitaly until you upgrade to GitLab 9.1 or later.
# Enable Gitaly in the init script # Enable Gitaly in the init script
echo 'gitaly_enabled=true' | sudo tee -a /etc/default/gitlab echo 'gitaly_enabled=true' | sudo tee -a /etc/default/gitlab
Next, edit `/home/git/gitlab/config/gitlab.yml` and make sure `socket_path` in Next, edit `/home/git/gitlab/config/gitlab.yml` and make sure `enabled: true` in
the `gitaly:` section is uncommented. the `gitaly:` section is uncommented.
# <- gitlab.yml indentation starts here # <- gitlab.yml indentation starts here
gitaly: gitaly:
socket_path: tmp/sockets/private/gitaly.socket enabled: true
For more information about configuring Gitaly see For more information about configuring Gitaly see
[doc/administration/gitaly](../administration/gitaly). [doc/administration/gitaly](../administration/gitaly).
......
# Topics
Welcome to Topics! We have organized our content resources into topics
to get you started on areas of your interest. Each topic page
consists of an index listing all related content. It will guide
you through better understanding GitLab's concepts
through our regular docs, and, when available, through articles (guides,
tutorials, technical overviews, blog posts) and videos.
- [GitLab Installation](../install/README.md)
- [Continuous Integration (GitLab CI)](../ci/README.md)
- [GitLab Pages](../user/project/pages/index.md)
>**Note:**
Non-linked topics are currently under development and subjected to change.
More topics will be available soon.
# From 9.0 to 9.1
** TODO: **
# TODO clean out 9.0-specific stuff
Make sure you view this update guide from the tag (version) of GitLab you would
like to install. In most cases this should be the highest numbered production
tag (without rc in it). You can select the tag in the version dropdown at the
top left corner of GitLab (below the menu bar).
If the highest number stable branch is unclear please check the
[GitLab Blog](https://about.gitlab.com/blog/archives.html) for installation
guide links by version.
### 1. Stop server
```bash
sudo service gitlab stop
```
### 2. Backup
```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
```
### 3. Update Ruby
NOTE: GitLab 9.0 and higher only support Ruby 2.3.x and dropped support for Ruby 2.1.x. Be
sure to upgrade your interpreter if necessary.
You can check which version you are running with `ruby -v`.
Download and compile Ruby:
```bash
mkdir /tmp/ruby && cd /tmp/ruby
curl --remote-name --progress https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.gz
echo '1014ee699071aa2ddd501907d18cbe15399c997d ruby-2.3.3.tar.gz' | shasum -c - && tar xzf ruby-2.3.3.tar.gz
cd ruby-2.3.3
./configure --disable-install-rdoc
make
sudo make install
```
Install Bundler:
```bash
sudo gem install bundler --no-ri --no-rdoc
```
### 4. Update Node
GitLab now runs [webpack](http://webpack.js.org) to compile frontend assets and
it has a minimum requirement of node v4.3.0.
You can check which version you are running with `node -v`. If you are running
a version older than `v4.3.0` you will need to update to a newer version. You
can find instructions to install from community maintained packages or compile
from source at the nodejs.org website.
<https://nodejs.org/en/download/>
Since 8.17, GitLab requires the use of yarn `>= v0.17.0` to manage
JavaScript dependencies.
```bash
curl --location https://yarnpkg.com/install.sh | bash -
```
More information can be found on the [yarn website](https://yarnpkg.com/en/docs/install).
### 5. Get latest code
```bash
cd /home/git/gitlab
sudo -u git -H git fetch --all
sudo -u git -H git checkout -- db/schema.rb # local changes will be restored automatically
```
For GitLab Community Edition:
```bash
cd /home/git/gitlab
sudo -u git -H git checkout 9-1-stable
```
OR
For GitLab Enterprise Edition:
```bash
cd /home/git/gitlab
sudo -u git -H git checkout 9-1-stable-ee
```
### 6. Update gitlab-shell
```bash
cd /home/git/gitlab-shell
sudo -u git -H git fetch --all --tags
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_SHELL_VERSION)
```
### 7. Update gitlab-workhorse
Install and compile gitlab-workhorse. This requires
[Go 1.5](https://golang.org/dl) which should already be on your system from
GitLab 8.1. GitLab-Workhorse uses [GNU Make](https://www.gnu.org/software/make/).
If you are not using Linux you may have to run `gmake` instead of
`make` below.
```bash
cd /home/git/gitlab-workhorse
sudo -u git -H git fetch --all --tags
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_WORKHORSE_VERSION)
sudo -u git -H make
```
### 8. Update configuration files
#### New configuration options for `gitlab.yml`
There might be configuration options available for [`gitlab.yml`][yaml]. View them with the command below and apply them manually to your current `gitlab.yml`:
```sh
cd /home/git/gitlab
git diff origin/9-0-stable:config/gitlab.yml.example origin/9-1-stable:config/gitlab.yml.example
```
#### Configuration changes for repository storages
This version introduces a new configuration structure for repository storages.
Update your current configuration as follows, replacing with your storages names and paths:
**For installations from source**
1. Update your `gitlab.yml`, from
```yaml
repositories:
storages: # You must have at least a 'default' storage path.
default: /home/git/repositories
nfs: /mnt/nfs/repositories
cephfs: /mnt/cephfs/repositories
```
to
```yaml
repositories:
storages: # You must have at least a 'default' storage path.
default:
path: /home/git/repositories
nfs:
path: /mnt/nfs/repositories
cephfs:
path: /mnt/cephfs/repositories
```
**For Omnibus installations**
1. Update your `/etc/gitlab/gitlab.rb`, from
```ruby
git_data_dirs({
"default" => "/var/opt/gitlab/git-data",
"nfs" => "/mnt/nfs/git-data",
"cephfs" => "/mnt/cephfs/git-data"
})
```
to
```ruby
git_data_dirs({
"default" => { "path" => "/var/opt/gitlab/git-data" },
"nfs" => { "path" => "/mnt/nfs/git-data" },
"cephfs" => { "path" => "/mnt/cephfs/git-data" }
})
```
#### Git configuration
Configure Git to generate packfile bitmaps (introduced in Git 2.0) on
the GitLab server during `git gc`.
```sh
cd /home/git/gitlab
sudo -u git -H git config --global repack.writeBitmaps true
```
#### Nginx configuration
Ensure you're still up-to-date with the latest NGINX configuration changes:
```sh
cd /home/git/gitlab
# For HTTPS configurations
git diff origin/9-0-stable:lib/support/nginx/gitlab-ssl origin/9-1-stable:lib/support/nginx/gitlab-ssl
# For HTTP configurations
git diff origin/9-0-stable:lib/support/nginx/gitlab origin/9-1-stable:lib/support/nginx/gitlab
```
If you are using Strict-Transport-Security in your installation to continue using it you must enable it in your Nginx
configuration as GitLab application no longer handles setting it.
If you are using Apache instead of NGINX please see the updated [Apache templates].
Also note that because Apache does not support upstreams behind Unix sockets you
will need to let gitlab-workhorse listen on a TCP port. You can do this
via [/etc/default/gitlab].
[Apache templates]: https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/apache
[/etc/default/gitlab]: https://gitlab.com/gitlab-org/gitlab-ce/blob/9-1-stable/lib/support/init.d/gitlab.default.example#L38
#### SMTP configuration
If you're installing from source and use SMTP to deliver mail, you will need to add the following line
to config/initializers/smtp_settings.rb:
```ruby
ActionMailer::Base.delivery_method = :smtp
```
See [smtp_settings.rb.sample] as an example.
[smtp_settings.rb.sample]: https://gitlab.com/gitlab-org/gitlab-ce/blob/9-0-stable/config/initializers/smtp_settings.rb.sample#L13
#### Init script
There might be new configuration options available for [`gitlab.default.example`][gl-example]. View them with the command below and apply them manually to your current `/etc/default/gitlab`:
```sh
cd /home/git/gitlab
git diff origin/9-0-stable:lib/support/init.d/gitlab.default.example origin/9-1-stable:lib/support/init.d/gitlab.default.example
```
Ensure you're still up-to-date with the latest init script changes:
```bash
cd /home/git/gitlab
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
```
For Ubuntu 16.04.1 LTS:
```bash
sudo systemctl daemon-reload
```
### 9. Install libs, migrations, etc.
```bash
cd /home/git/gitlab
# MySQL installations (note: the line below states '--without postgres')
sudo -u git -H bundle install --without postgres development test --deployment
# PostgreSQL installations (note: the line below states '--without mysql')
sudo -u git -H bundle install --without mysql development test --deployment
# Optional: clean up old gems
sudo -u git -H bundle clean
# Run database migrations
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
# Update node dependencies and recompile assets
sudo -u git -H bundle exec rake yarn:install gitlab:assets:clean gitlab:assets:compile RAILS_ENV=production NODE_ENV=production
# Clean up cache
sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production
```
**MySQL installations**: Run through the `MySQL strings limits` and `Tables and data conversion to utf8mb4` [tasks](../install/database_mysql.md).
### 10. Optional: install Gitaly
Gitaly is still an optional component of GitLab. If you want to save time
during your 9.1 upgrade **you can skip this step**.
If you have not yet set up Gitaly then follow [Gitaly section of the installation
guide](../install/installation.md#install-gitaly).
If you installed Gitaly in GitLab 9.0 you need to make some changes in gitlab.yml.
Look for `socket_path:` the `gitaly:` section. Its value is usually
`/home/git/gitlab/tmp/sockets/private/gitaly.socket`. Note what socket
path your gitlab.yml is using. Now go to the `repositories:` section,
and for each entry under `storages:`, add a `gitaly_address:` based on
the socket path, but with `unix:` in front.
```yaml
repositories:
storages:
default:
path: /home/git/repositories
gitaly_address: unix:/home/git/gitlab/tmp/sockets/private/gitaly.socket
other_storage:
path: /home/git/other-repositories
gitaly_address: unix:/home/git/gitlab/tmp/sockets/private/gitaly.socket
```
Each entry under `storages:` should use the same `gitaly_address`.
### 11. Start application
```bash
sudo service gitlab start
sudo service nginx restart
```
### 12. Check application status
Check if GitLab and its environment are configured correctly:
```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
```
To make sure you didn't miss anything run a more thorough check:
```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
```
If all items are green, then congratulations, the upgrade is complete!
## Things went south? Revert to previous version (9.0)
### 1. Revert the code to the previous version
Follow the [upgrade guide from 8.17 to 9.0](8.17-to-9.0.md), except for the
database migration (the backup is already migrated to the previous version).
### 2. Restore from the backup
```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
```
If you have more than one backup `*.tar` file(s) please add `BACKUP=timestamp_of_backup` to the command above.
[yaml]: https://gitlab.com/gitlab-org/gitlab-ce/blob/9-1-stable/config/gitlab.yml.example
[gl-example]: https://gitlab.com/gitlab-org/gitlab-ce/blob/9-1-stable/lib/support/init.d/gitlab.default.example
# GitLab Pages from A to Z: Part 4 # GitLab Pages from A to Z: Part 4
> **Type**: user guide ||
> **Level**: intermediate ||
> **Author**: [Marcia Ramos](https://gitlab.com/marcia)
- [Part 1: Static sites and GitLab Pages domains](getting_started_part_one.md) - [Part 1: Static sites and GitLab Pages domains](getting_started_part_one.md)
- [Part 2: Quick start guide - Setting up GitLab Pages](getting_started_part_two.md) - [Part 2: Quick start guide - Setting up GitLab Pages](getting_started_part_two.md)
- [Part 3: Setting Up Custom Domains - DNS Records and SSL/TLS Certificates](getting_started_part_three.md) - [Part 3: Setting Up Custom Domains - DNS Records and SSL/TLS Certificates](getting_started_part_three.md)
......
# GitLab Pages from A to Z: Part 1 # GitLab Pages from A to Z: Part 1
> **Type**: user guide ||
> **Level**: beginner ||
> **Author**: [Marcia Ramos](https://gitlab.com/marcia)
- **Part 1: Static sites and GitLab Pages domains** - **Part 1: Static sites and GitLab Pages domains**
- [Part 2: Quick start guide - Setting up GitLab Pages](getting_started_part_two.md) - [Part 2: Quick start guide - Setting up GitLab Pages](getting_started_part_two.md)
- [Part 3: Setting Up Custom Domains - DNS Records and SSL/TLS Certificates](getting_started_part_three.md) - [Part 3: Setting Up Custom Domains - DNS Records and SSL/TLS Certificates](getting_started_part_three.md)
......
# GitLab Pages from A to Z: Part 3 # GitLab Pages from A to Z: Part 3
> **Type**: user guide ||
> **Level**: beginner ||
> **Author**: [Marcia Ramos](https://gitlab.com/marcia)
- [Part 1: Static sites and GitLab Pages domains](getting_started_part_one.md) - [Part 1: Static sites and GitLab Pages domains](getting_started_part_one.md)
- [Part 2: Quick start guide - Setting up GitLab Pages](getting_started_part_two.md) - [Part 2: Quick start guide - Setting up GitLab Pages](getting_started_part_two.md)
- **Part 3: Setting Up Custom Domains - DNS Records and SSL/TLS Certificates** - **Part 3: Setting Up Custom Domains - DNS Records and SSL/TLS Certificates**
......
# GitLab Pages from A to Z: Part 2 # GitLab Pages from A to Z: Part 2
> **Type**: user guide ||
> **Level**: beginner ||
> **Author**: [Marcia Ramos](https://gitlab.com/marcia)
- [Part 1: Static sites and GitLab Pages domains](getting_started_part_one.md) - [Part 1: Static sites and GitLab Pages domains](getting_started_part_one.md)
- **Part 2: Quick start guide - Setting up GitLab Pages** - **Part 2: Quick start guide - Setting up GitLab Pages**
- [Part 3: Setting Up Custom Domains - DNS Records and SSL/TLS Certificates](getting_started_part_three.md) - [Part 3: Setting Up Custom Domains - DNS Records and SSL/TLS Certificates](getting_started_part_three.md)
......
...@@ -28,7 +28,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps ...@@ -28,7 +28,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
merge_request_reference = merge_request.to_reference(full: true) merge_request_reference = merge_request.to_reference(full: true)
issue_reference = issue.to_reference(full: true) issue_reference = issue.to_reference(full: true)
page.within('.todos-pending-count') { expect(page).to have_content '4' } page.within('.todos-count') { expect(page).to have_content '4' }
expect(page).to have_content 'To do 4' expect(page).to have_content 'To do 4'
expect(page).to have_content 'Done 0' expect(page).to have_content 'Done 0'
...@@ -44,7 +44,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps ...@@ -44,7 +44,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
click_link 'Done' click_link 'Done'
end end
page.within('.todos-pending-count') { expect(page).to have_content '3' } page.within('.todos-count') { expect(page).to have_content '3' }
expect(page).to have_content 'To do 3' expect(page).to have_content 'To do 3'
expect(page).to have_content 'Done 1' expect(page).to have_content 'Done 1'
should_see_todo(1, "John Doe assigned you merge request #{merge_request.to_reference(full: true)}", merge_request.title, state: :done_reversible) should_see_todo(1, "John Doe assigned you merge request #{merge_request.to_reference(full: true)}", merge_request.title, state: :done_reversible)
...@@ -56,7 +56,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps ...@@ -56,7 +56,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
click_link 'Mark all as done' click_link 'Mark all as done'
page.within('.todos-pending-count') { expect(page).to have_content '0' } page.within('.todos-count') { expect(page).to have_content '0' }
expect(page).to have_content 'To do 0' expect(page).to have_content 'To do 0'
expect(page).to have_content 'Done 4' expect(page).to have_content 'Done 4'
expect(page).to have_content "You're all done!" expect(page).to have_content "You're all done!"
......
...@@ -153,7 +153,7 @@ module API ...@@ -153,7 +153,7 @@ module API
return unless Gitlab::GitalyClient.enabled? return unless Gitlab::GitalyClient.enabled?
begin begin
Gitlab::GitalyClient::Notifications.new.post_receive(params[:repo_path]) Gitlab::GitalyClient::Notifications.new(params[:repo_path]).post_receive
rescue GRPC::Unavailable => e rescue GRPC::Unavailable => e
render_api_error(e, 500) render_api_error(e, 500)
end end
......
...@@ -65,14 +65,14 @@ module API ...@@ -65,14 +65,14 @@ module API
success Entities::IssueBasic success Entities::IssueBasic
end end
params do params do
optional :state, type: String, values: %w[opened closed all], default: 'opened', optional :state, type: String, values: %w[opened closed all], default: 'all',
desc: 'Return opened, closed, or all issues' desc: 'Return opened, closed, or all issues'
use :issues_params use :issues_params
end end
get ":id/issues" do get ":id/issues" do
group = find_group!(params[:id]) group = find_group!(params[:id])
issues = find_issues(group_id: group.id, state: params[:state] || 'opened') issues = find_issues(group_id: group.id)
present paginate(issues), with: Entities::IssueBasic, current_user: current_user present paginate(issues), with: Entities::IssueBasic, current_user: current_user
end end
......
...@@ -23,7 +23,7 @@ module API ...@@ -23,7 +23,7 @@ module API
end end
params do params do
requires :name, type: String, desc: 'The name of the label to be created' requires :name, type: String, desc: 'The name of the label to be created'
requires :color, type: String, desc: "The color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB)" requires :color, type: String, desc: "The color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the allowed CSS color names"
optional :description, type: String, desc: 'The description of label to be created' optional :description, type: String, desc: 'The description of label to be created'
optional :priority, type: Integer, desc: 'The priority of the label', allow_blank: true optional :priority, type: Integer, desc: 'The priority of the label', allow_blank: true
end end
...@@ -34,7 +34,7 @@ module API ...@@ -34,7 +34,7 @@ module API
conflict!('Label already exists') if label conflict!('Label already exists') if label
priority = params.delete(:priority) priority = params.delete(:priority)
label = user_project.labels.create(declared_params(include_missing: false)) label = ::Labels::CreateService.new(declared_params(include_missing: false)).execute(project: user_project)
if label.valid? if label.valid?
label.prioritize!(user_project, priority) if priority label.prioritize!(user_project, priority) if priority
...@@ -65,7 +65,7 @@ module API ...@@ -65,7 +65,7 @@ module API
params do params do
requires :name, type: String, desc: 'The name of the label to be updated' requires :name, type: String, desc: 'The name of the label to be updated'
optional :new_name, type: String, desc: 'The new name of the label' optional :new_name, type: String, desc: 'The new name of the label'
optional :color, type: String, desc: "The new color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB)" optional :color, type: String, desc: "The new color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the allowed CSS color names"
optional :description, type: String, desc: 'The new description of label' optional :description, type: String, desc: 'The new description of label'
optional :priority, type: Integer, desc: 'The priority of the label', allow_blank: true optional :priority, type: Integer, desc: 'The priority of the label', allow_blank: true
at_least_one_of :new_name, :color, :description, :priority at_least_one_of :new_name, :color, :description, :priority
...@@ -82,7 +82,8 @@ module API ...@@ -82,7 +82,8 @@ module API
# Rename new name to the actual label attribute name # Rename new name to the actual label attribute name
label_params[:name] = label_params.delete(:new_name) if label_params.key?(:new_name) label_params[:name] = label_params.delete(:new_name) if label_params.key?(:new_name)
render_validation_error!(label) unless label.update(label_params) label = ::Labels::UpdateService.new(label_params).execute(label)
render_validation_error!(label) unless label.valid?
if update_priority if update_priority
if priority.nil? if priority.nil?
......
...@@ -233,18 +233,6 @@ module API ...@@ -233,18 +233,6 @@ module API
.cancel(merge_request) .cancel(merge_request)
end end
desc 'List issues that will be closed on merge' do
success Entities::MRNote
end
params do
use :pagination
end
get ':id/merge_requests/:merge_request_iid/closes_issues' do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
issues = ::Kaminari.paginate_array(merge_request.closes_issues(current_user))
present paginate(issues), with: issue_entity(user_project), current_user: current_user
end
# Get the status of the merge request's approvals # Get the status of the merge request's approvals
# #
# Parameters: # Parameters:
......
...@@ -74,14 +74,14 @@ module API ...@@ -74,14 +74,14 @@ module API
success ::API::Entities::Issue success ::API::Entities::Issue
end end
params do params do
optional :state, type: String, values: %w[opened closed all], default: 'opened', optional :state, type: String, values: %w[opened closed all], default: 'all',
desc: 'Return opened, closed, or all issues' desc: 'Return opened, closed, or all issues'
use :issues_params use :issues_params
end end
get ":id/issues" do get ":id/issues" do
group = find_group!(params[:id]) group = find_group!(params[:id])
issues = find_issues(group_id: group.id, state: params[:state] || 'opened', match_all_labels: true) issues = find_issues(group_id: group.id, match_all_labels: true)
present paginate(issues), with: ::API::Entities::Issue, current_user: current_user present paginate(issues), with: ::API::Entities::Issue, current_user: current_user
end end
......
...@@ -182,7 +182,9 @@ module Backup ...@@ -182,7 +182,9 @@ module Backup
dir_entries = Dir.entries(path) dir_entries = Dir.entries(path)
yield('custom_hooks') if dir_entries.include?('custom_hooks') if dir_entries.include?('custom_hooks') || dir_entries.include?('custom_hooks.tar')
yield('custom_hooks')
end
end end
def prepare def prepare
......
...@@ -130,8 +130,13 @@ module Gitlab ...@@ -130,8 +130,13 @@ module Gitlab
end end
def create_labels def create_labels
LABELS.each do |label| LABELS.each do |label_params|
@labels[label[:title]] = project.labels.create!(label) label = ::Labels::CreateService.new(label_params).execute(project: project)
if label.valid?
@labels[label_params[:title]] = label
else
raise "Failed to create label \"#{label_params[:title]}\" for project \"#{project.name_with_namespace}\""
end
end end
end end
......
...@@ -4,28 +4,30 @@ module Gitlab ...@@ -4,28 +4,30 @@ module Gitlab
module GitalyClient module GitalyClient
SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION'.freeze SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION'.freeze
def self.gitaly_address def self.configure_channel(storage, address)
if Gitlab.config.gitaly.socket_path @addresses ||= {}
"unix://#{Gitlab.config.gitaly.socket_path}" @addresses[storage] = address
end @channels ||= {}
@channels[storage] = new_channel(address)
end
def self.new_channel(address)
# NOTE: Gitaly currently runs on a Unix socket, so permissions are
# handled using the file system and no additional authentication is
# required (therefore the :this_channel_is_insecure flag)
GRPC::Core::Channel.new(address, {}, :this_channel_is_insecure)
end end
def self.channel def self.get_channel(storage)
return @channel if defined?(@channel) @channels[storage]
end
@channel = def self.get_address(storage)
if enabled? @addresses[storage]
# NOTE: Gitaly currently runs on a Unix socket, so permissions are
# handled using the file system and no additional authentication is
# required (therefore the :this_channel_is_insecure flag)
GRPC::Core::Channel.new(gitaly_address, {}, :this_channel_is_insecure)
else
nil
end
end end
def self.enabled? def self.enabled?
gitaly_address.present? Gitlab.config.gitaly.enabled
end end
def self.feature_enabled?(feature) def self.feature_enabled?(feature)
......
...@@ -7,8 +7,10 @@ module Gitlab ...@@ -7,8 +7,10 @@ module Gitlab
class << self class << self
def diff_from_parent(commit, options = {}) def diff_from_parent(commit, options = {})
stub = Gitaly::Diff::Stub.new(nil, nil, channel_override: GitalyClient.channel) project = commit.project
repo = Gitaly::Repository.new(path: commit.project.repository.path_to_repo) channel = GitalyClient.get_channel(project.repository_storage)
stub = Gitaly::Diff::Stub.new(nil, nil, channel_override: channel)
repo = Gitaly::Repository.new(path: project.repository.path_to_repo)
parent = commit.parents[0] parent = commit.parents[0]
parent_id = parent ? parent.id : EMPTY_TREE_ID parent_id = parent ? parent.id : EMPTY_TREE_ID
request = Gitaly::CommitDiffRequest.new( request = Gitaly::CommitDiffRequest.new(
......
...@@ -3,14 +3,19 @@ module Gitlab ...@@ -3,14 +3,19 @@ module Gitlab
class Notifications class Notifications
attr_accessor :stub attr_accessor :stub
def initialize def initialize(repo_path)
@stub = Gitaly::Notifications::Stub.new(nil, nil, channel_override: GitalyClient.channel) full_path = Gitlab::RepoPath.strip_storage_path(repo_path).
sub(/\.git\z/, '').sub(/\.wiki\z/, '')
@project = Project.find_by_full_path(full_path)
channel = GitalyClient.get_channel(@project.repository_storage)
@stub = Gitaly::Notifications::Stub.new(nil, nil, channel_override: channel)
end end
def post_receive(repo_path) def post_receive
repository = Gitaly::Repository.new(path: repo_path) repository = Gitaly::Repository.new(path: @project.repository.path_to_repo)
request = Gitaly::PostReceiveRequest.new(repository: repository) request = Gitaly::PostReceiveRequest.new(repository: repository)
stub.post_receive(request) @stub.post_receive(request)
end end
end end
end end
......
module Gitlab
module RepoPath
NotFoundError = Class.new(StandardError)
def self.strip_storage_path(repo_path)
result = nil
Gitlab.config.repositories.storages.values.each do |params|
storage_path = params['path']
if repo_path.start_with?(storage_path)
result = repo_path.sub(storage_path, '')
break
end
end
if result.nil?
raise NotFoundError.new("No known storage path matches #{repo_path.inspect}")
end
result.sub(/\A\/*/, '')
end
end
end
module Gitlab module Gitlab
class UploadsTransfer < ProjectTransfer class UploadsTransfer < ProjectTransfer
def root_dir def root_dir
File.join(Rails.root, "public", "uploads") File.join(CarrierWave.root, GitlabUploader.base_dir)
end end
end end
end end
require 'base64' require 'base64'
require 'json' require 'json'
require 'securerandom' require 'securerandom'
require 'uri'
module Gitlab module Gitlab
class Workhorse class Workhorse
...@@ -21,10 +22,10 @@ module Gitlab ...@@ -21,10 +22,10 @@ module Gitlab
RepoPath: repository.path_to_repo, RepoPath: repository.path_to_repo,
} }
params.merge!( if Gitlab.config.gitaly.enabled
GitalySocketPath: Gitlab.config.gitaly.socket_path, address = Gitlab::GitalyClient.get_address(repository.project.repository_storage)
GitalyResourcePath: "/projects/#{repository.project.id}/git-http/info-refs", params[:GitalySocketPath] = URI(address).path
) if Gitlab.config.gitaly.socket_path.present? end
params params
end end
......
...@@ -618,7 +618,7 @@ namespace :gitlab do ...@@ -618,7 +618,7 @@ namespace :gitlab do
end end
def sidekiq_process_count def sidekiq_process_count
ps_ux, _ = Gitlab::Popen.popen(%w(ps ux)) ps_ux, _ = Gitlab::Popen.popen(%w(ps uxww))
ps_ux.scan(/sidekiq \d+\.\d+\.\d+/).count ps_ux.scan(/sidekiq \d+\.\d+\.\d+/).count
end end
end end
...@@ -752,7 +752,7 @@ namespace :gitlab do ...@@ -752,7 +752,7 @@ namespace :gitlab do
end end
def mail_room_running? def mail_room_running?
ps_ux, _ = Gitlab::Popen.popen(%w(ps ux)) ps_ux, _ = Gitlab::Popen.popen(%w(ps uxww))
ps_ux.include?("mail_room") ps_ux.include?("mail_room")
end end
end end
......
unless Rails.env.production? unless Rails.env.production?
namespace :karma do namespace :karma do
desc 'GitLab | Karma | Generate fixtures for JavaScript tests' desc 'GitLab | Karma | Generate fixtures for JavaScript tests'
RSpec::Core::RakeTask.new(:fixtures) do |t| RSpec::Core::RakeTask.new(:fixtures, [:pattern]) do |t, args|
args.with_defaults(pattern: 'spec/javascripts/fixtures/*.rb')
ENV['NO_KNAPSACK'] = 'true' ENV['NO_KNAPSACK'] = 'true'
t.pattern = 'spec/javascripts/fixtures/*.rb' t.pattern = args[:pattern]
t.rspec_opts = '--format documentation' t.rspec_opts = '--format documentation'
end end
......
...@@ -100,6 +100,16 @@ feature 'Group', feature: true do ...@@ -100,6 +100,16 @@ feature 'Group', feature: true do
end end
end end
it 'checks permissions to avoid exposing groups by parent_id' do
group = create(:group, :private, path: 'secret-group')
logout
login_as(:user)
visit new_group_path(parent_id: group.id)
expect(page).not_to have_content('secret-group')
end
describe 'group edit' do describe 'group edit' do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:path) { edit_group_path(group) } let(:path) { edit_group_path(group) }
......
...@@ -43,10 +43,10 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -43,10 +43,10 @@ describe 'Dropdown hint', js: true, feature: true do
end end
describe 'filtering' do describe 'filtering' do
it 'does not filter `Keep typing and press Enter`' do it 'does not filter `Press Enter or click to search`' do
filtered_search.set('randomtext') filtered_search.set('randomtext')
expect(page).to have_css(js_dropdown_hint, text: 'Keep typing and press Enter', visible: false) expect(page).to have_css(js_dropdown_hint, text: 'Press Enter or click to search', visible: false)
expect(dropdown_hint_size).to eq(0) expect(dropdown_hint_size).to eq(0)
end end
......
...@@ -17,13 +17,13 @@ feature 'Manually create a todo item from issue', feature: true, js: true do ...@@ -17,13 +17,13 @@ feature 'Manually create a todo item from issue', feature: true, js: true do
expect(page).to have_content 'Mark done' expect(page).to have_content 'Mark done'
end end
page.within '.header-content .todos-pending-count' do page.within '.header-content .todos-count' do
expect(page).to have_content '1' expect(page).to have_content '1'
end end
visit namespace_project_issue_path(project.namespace, project, issue) visit namespace_project_issue_path(project.namespace, project, issue)
page.within '.header-content .todos-pending-count' do page.within '.header-content .todos-count' do
expect(page).to have_content '1' expect(page).to have_content '1'
end end
end end
...@@ -34,10 +34,10 @@ feature 'Manually create a todo item from issue', feature: true, js: true do ...@@ -34,10 +34,10 @@ feature 'Manually create a todo item from issue', feature: true, js: true do
click_button 'Mark done' click_button 'Mark done'
end end
expect(page).to have_selector('.todos-pending-count', visible: false) expect(page).to have_selector('.todos-count', visible: false)
visit namespace_project_issue_path(project.namespace, project, issue) visit namespace_project_issue_path(project.namespace, project, issue)
expect(page).to have_selector('.todos-pending-count', visible: false) expect(page).to have_selector('.todos-count', visible: false)
end end
end end
...@@ -251,7 +251,7 @@ describe 'Dashboard Todos', feature: true do ...@@ -251,7 +251,7 @@ describe 'Dashboard Todos', feature: true do
end end
it 'shows "All done" message' do it 'shows "All done" message' do
within('.todos-pending-count') { expect(page).to have_content '0' } within('.todos-count') { expect(page).to have_content '0' }
expect(page).to have_content 'To do 0' expect(page).to have_content 'To do 0'
expect(page).to have_content 'Done 0' expect(page).to have_content 'Done 0'
expect(page).to have_selector('.todos-all-done', count: 1) expect(page).to have_selector('.todos-all-done', count: 1)
...@@ -267,7 +267,7 @@ describe 'Dashboard Todos', feature: true do ...@@ -267,7 +267,7 @@ describe 'Dashboard Todos', feature: true do
end end
it 'shows 99+ for count >= 100 in notification' do it 'shows 99+ for count >= 100 in notification' do
expect(page).to have_selector('.todos-pending-count', text: '99+') expect(page).to have_selector('.todos-count', text: '99+')
end end
it 'shows exact number in To do tab' do it 'shows exact number in To do tab' do
...@@ -277,7 +277,7 @@ describe 'Dashboard Todos', feature: true do ...@@ -277,7 +277,7 @@ describe 'Dashboard Todos', feature: true do
it 'shows exact number for count < 100' do it 'shows exact number for count < 100' do
3.times { first('.js-done-todo').click } 3.times { first('.js-done-todo').click }
expect(page).to have_selector('.todos-pending-count', text: '98') expect(page).to have_selector('.todos-count', text: '98')
end end
end end
......
/* global Sidebar */
/* eslint-disable no-new */
import _ from 'underscore';
import '~/right_sidebar';
describe('Issuable right sidebar collapsed todo toggle', () => {
const fixtureName = 'issues/open-issue.html.raw';
const jsonFixtureName = 'todos/todos.json';
preloadFixtures(fixtureName);
preloadFixtures(jsonFixtureName);
beforeEach(() => {
const todoData = getJSONFixture(jsonFixtureName);
new Sidebar();
loadFixtures(fixtureName);
document.querySelector('.js-right-sidebar')
.classList.toggle('right-sidebar-expanded');
document.querySelector('.js-right-sidebar')
.classList.toggle('right-sidebar-collapsed');
spyOn(jQuery, 'ajax').and.callFake((res) => {
const d = $.Deferred();
const response = _.clone(todoData);
if (res.type === 'DELETE') {
delete response.delete_path;
}
d.resolve(response);
return d.promise();
});
});
it('shows add todo button', () => {
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon'),
).not.toBeNull();
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon .fa-plus-square'),
).not.toBeNull();
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon .todo-undone'),
).toBeNull();
});
it('sets default tooltip title', () => {
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').getAttribute('title'),
).toBe('Add todo');
});
it('toggle todo state', () => {
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').click();
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon .todo-undone'),
).not.toBeNull();
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon .fa-check-square'),
).not.toBeNull();
});
it('toggle todo state of expanded todo toggle', () => {
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').click();
expect(
document.querySelector('.issuable-sidebar-header .js-issuable-todo').textContent.trim(),
).toBe('Mark done');
});
it('toggles todo button tooltip', () => {
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').click();
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').getAttribute('data-original-title'),
).toBe('Mark done');
});
it('marks todo as done', () => {
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').click();
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon .todo-undone'),
).not.toBeNull();
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').click();
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon .todo-undone'),
).toBeNull();
expect(
document.querySelector('.issuable-sidebar-header .js-issuable-todo').textContent.trim(),
).toBe('Add todo');
});
it('updates aria-label to mark done', () => {
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').click();
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').getAttribute('aria-label'),
).toBe('Mark done');
});
it('updates aria-label to add todo', () => {
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').click();
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').getAttribute('aria-label'),
).toBe('Mark done');
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').click();
expect(
document.querySelector('.js-issuable-todo.sidebar-collapsed-icon').getAttribute('aria-label'),
).toBe('Add todo');
});
});
...@@ -9,7 +9,7 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -9,7 +9,7 @@ describe('Pipelines table in Commits and Merge requests', () => {
loadFixtures('static/pipelines_table.html.raw'); loadFixtures('static/pipelines_table.html.raw');
}); });
describe('successfull request', () => { describe('successful request', () => {
describe('without pipelines', () => { describe('without pipelines', () => {
const pipelinesEmptyResponse = (request, next) => { const pipelinesEmptyResponse = (request, next) => {
next(request.respondWith(JSON.stringify([]), { next(request.respondWith(JSON.stringify([]), {
...@@ -17,24 +17,25 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -17,24 +17,25 @@ describe('Pipelines table in Commits and Merge requests', () => {
})); }));
}; };
beforeEach(() => { beforeEach(function () {
Vue.http.interceptors.push(pipelinesEmptyResponse); Vue.http.interceptors.push(pipelinesEmptyResponse);
this.component = new PipelinesTable({
el: document.querySelector('#commit-pipeline-table-view'),
});
}); });
afterEach(() => { afterEach(function () {
Vue.http.interceptors = _.without( Vue.http.interceptors = _.without(
Vue.http.interceptors, pipelinesEmptyResponse, Vue.http.interceptors, pipelinesEmptyResponse,
); );
this.component.$destroy();
}); });
it('should render the empty state', (done) => { it('should render the empty state', function (done) {
const component = new PipelinesTable({
el: document.querySelector('#commit-pipeline-table-view'),
});
setTimeout(() => { setTimeout(() => {
expect(component.$el.querySelector('.empty-state')).toBeDefined(); expect(this.component.$el.querySelector('.empty-state')).toBeDefined();
expect(component.$el.querySelector('.realtime-loading')).toBe(null); expect(this.component.$el.querySelector('.realtime-loading')).toBe(null);
done(); done();
}, 1); }, 1);
}); });
...@@ -49,22 +50,23 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -49,22 +50,23 @@ describe('Pipelines table in Commits and Merge requests', () => {
beforeEach(() => { beforeEach(() => {
Vue.http.interceptors.push(pipelinesResponse); Vue.http.interceptors.push(pipelinesResponse);
this.component = new PipelinesTable({
el: document.querySelector('#commit-pipeline-table-view'),
});
}); });
afterEach(() => { afterEach(() => {
Vue.http.interceptors = _.without( Vue.http.interceptors = _.without(
Vue.http.interceptors, pipelinesResponse, Vue.http.interceptors, pipelinesResponse,
); );
this.component.$destroy();
}); });
it('should render a table with the received pipelines', (done) => { it('should render a table with the received pipelines', (done) => {
const component = new PipelinesTable({
el: document.querySelector('#commit-pipeline-table-view'),
});
setTimeout(() => { setTimeout(() => {
expect(component.$el.querySelectorAll('table > tbody > tr').length).toEqual(1); expect(this.component.$el.querySelectorAll('table > tbody > tr').length).toEqual(1);
expect(component.$el.querySelector('.realtime-loading')).toBe(null); expect(this.component.$el.querySelector('.realtime-loading')).toBe(null);
done(); done();
}, 0); }, 0);
}); });
...@@ -78,24 +80,25 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -78,24 +80,25 @@ describe('Pipelines table in Commits and Merge requests', () => {
})); }));
}; };
beforeEach(() => { beforeEach(function () {
Vue.http.interceptors.push(pipelinesErrorResponse); Vue.http.interceptors.push(pipelinesErrorResponse);
this.component = new PipelinesTable({
el: document.querySelector('#commit-pipeline-table-view'),
});
}); });
afterEach(() => { afterEach(function () {
Vue.http.interceptors = _.without( Vue.http.interceptors = _.without(
Vue.http.interceptors, pipelinesErrorResponse, Vue.http.interceptors, pipelinesErrorResponse,
); );
this.component.$destroy();
}); });
it('should render empty state', (done) => { it('should render empty state', function (done) {
const component = new PipelinesTable({
el: document.querySelector('#commit-pipeline-table-view'),
});
setTimeout(() => { setTimeout(() => {
expect(component.$el.querySelector('.js-pipelines-error-state')).toBeDefined(); expect(this.component.$el.querySelector('.js-pipelines-error-state')).toBeDefined();
expect(component.$el.querySelector('.realtime-loading')).toBe(null); expect(this.component.$el.querySelector('.realtime-loading')).toBe(null);
done(); done();
}, 0); }, 0);
}); });
......
...@@ -6,6 +6,15 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont ...@@ -6,6 +6,15 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, namespace: namespace, path: 'merge-requests-project') } let(:project) { create(:project, namespace: namespace, path: 'merge-requests-project') }
let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') }
let(:pipeline) do
create(
:ci_pipeline,
project: merge_request.source_project,
ref: merge_request.source_branch,
sha: merge_request.diff_head_sha
)
end
render_views render_views
...@@ -18,7 +27,8 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont ...@@ -18,7 +27,8 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
end end
it 'merge_requests/merge_request_with_task_list.html.raw' do |example| it 'merge_requests/merge_request_with_task_list.html.raw' do |example|
merge_request = create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') create(:ci_build, :pending, pipeline: pipeline)
render_merge_request(example.description, merge_request) render_merge_request(example.description, merge_request)
end end
......
...@@ -5,7 +5,7 @@ require('~/lib/utils/text_utility'); ...@@ -5,7 +5,7 @@ require('~/lib/utils/text_utility');
(function() { (function() {
describe('Header', function() { describe('Header', function() {
var todosPendingCount = '.todos-pending-count'; var todosPendingCount = '.todos-count';
var fixtureTemplate = 'issues/open-issue.html.raw'; var fixtureTemplate = 'issues/open-issue.html.raw';
function isTodosCountHidden() { function isTodosCountHidden() {
...@@ -21,31 +21,31 @@ require('~/lib/utils/text_utility'); ...@@ -21,31 +21,31 @@ require('~/lib/utils/text_utility');
loadFixtures(fixtureTemplate); loadFixtures(fixtureTemplate);
}); });
it('should update todos-pending-count after receiving the todo:toggle event', function() { it('should update todos-count after receiving the todo:toggle event', function() {
triggerToggle(5); triggerToggle(5);
expect($(todosPendingCount).text()).toEqual('5'); expect($(todosPendingCount).text()).toEqual('5');
}); });
it('should hide todos-pending-count when it is 0', function() { it('should hide todos-count when it is 0', function() {
triggerToggle(0); triggerToggle(0);
expect(isTodosCountHidden()).toEqual(true); expect(isTodosCountHidden()).toEqual(true);
}); });
it('should show todos-pending-count when it is more than 0', function() { it('should show todos-count when it is more than 0', function() {
triggerToggle(10); triggerToggle(10);
expect(isTodosCountHidden()).toEqual(false); expect(isTodosCountHidden()).toEqual(false);
}); });
describe('when todos-pending-count is 1000', function() { describe('when todos-count is 1000', function() {
beforeEach(function() { beforeEach(function() {
triggerToggle(1000); triggerToggle(1000);
}); });
it('should show todos-pending-count', function() { it('should show todos-count', function() {
expect(isTodosCountHidden()).toEqual(false); expect(isTodosCountHidden()).toEqual(false);
}); });
it('should show 99+ for todos-pending-count', function() { it('should show 99+ for todos-count', function() {
expect($(todosPendingCount).text()).toEqual('99+'); expect($(todosPendingCount).text()).toEqual('99+');
}); });
}); });
......
...@@ -38,6 +38,10 @@ require('vendor/jquery.scrollTo'); ...@@ -38,6 +38,10 @@ require('vendor/jquery.scrollTo');
} }
}); });
afterEach(function () {
this.class.destroy();
});
describe('#activateTab', function () { describe('#activateTab', function () {
beforeEach(function () { beforeEach(function () {
spyOn($, 'ajax').and.callFake(function () {}); spyOn($, 'ajax').and.callFake(function () {});
...@@ -200,6 +204,42 @@ require('vendor/jquery.scrollTo'); ...@@ -200,6 +204,42 @@ require('vendor/jquery.scrollTo');
expect(this.subject('show')).toBe('/foo/bar/merge_requests/1'); expect(this.subject('show')).toBe('/foo/bar/merge_requests/1');
}); });
}); });
describe('#tabShown', () => {
beforeEach(function () {
loadFixtures('merge_requests/merge_request_with_task_list.html.raw');
});
describe('with "Side-by-side"/parallel diff view', () => {
beforeEach(function () {
this.class.diffViewType = () => 'parallel';
});
it('maintains `container-limited` for pipelines tab', function (done) {
const asyncClick = function (selector) {
return new Promise((resolve) => {
setTimeout(() => {
document.querySelector(selector).click();
resolve();
});
});
};
asyncClick('.merge-request-tabs .pipelines-tab a')
.then(() => asyncClick('.merge-request-tabs .diffs-tab a'))
.then(() => asyncClick('.merge-request-tabs .pipelines-tab a'))
.then(() => {
const hasContainerLimitedClass = document.querySelector('.content-wrapper .container-fluid').classList.contains('container-limited');
expect(hasContainerLimitedClass).toBe(true);
})
.then(done)
.catch((err) => {
done.fail(`Something went wrong clicking MR tabs: ${err.message}\n${err.stack}`);
});
});
});
});
describe('#loadDiff', function () { describe('#loadDiff', function () {
it('requires an absolute pathname', function () { it('requires an absolute pathname', function () {
spyOn($, 'ajax').and.callFake(function (options) { spyOn($, 'ajax').and.callFake(function (options) {
......
...@@ -74,7 +74,7 @@ import '~/right_sidebar'; ...@@ -74,7 +74,7 @@ import '~/right_sidebar';
var todoToggleSpy = spyOnEvent(document, 'todo:toggle'); var todoToggleSpy = spyOnEvent(document, 'todo:toggle');
$('.js-issuable-todo').click(); $('.issuable-sidebar-header .js-issuable-todo').click();
expect(todoToggleSpy.calls.count()).toEqual(1); expect(todoToggleSpy.calls.count()).toEqual(1);
}); });
......
...@@ -21,6 +21,10 @@ describe('Pipelines Table', () => { ...@@ -21,6 +21,10 @@ describe('Pipelines Table', () => {
}).$mount(); }).$mount();
}); });
afterEach(() => {
component.$destroy();
});
it('should render a table', () => { it('should render a table', () => {
expect(component.$el).toEqual('TABLE'); expect(component.$el).toEqual('TABLE');
}); });
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::GitalyClient::Notifications do describe Gitlab::GitalyClient::Notifications do
let(:client) { Gitlab::GitalyClient::Notifications.new }
before do
allow(Gitlab.config.gitaly).to receive(:socket_path).and_return('path/to/gitaly.socket')
end
describe '#post_receive' do describe '#post_receive' do
let(:repo_path) { '/path/to/my_repo.git' }
it 'sends a post_receive message' do it 'sends a post_receive message' do
repo_path = create(:empty_project).repository.path_to_repo
expect_any_instance_of(Gitaly::Notifications::Stub). expect_any_instance_of(Gitaly::Notifications::Stub).
to receive(:post_receive).with(post_receive_request_with_repo_path(repo_path)) to receive(:post_receive).with(post_receive_request_with_repo_path(repo_path))
client.post_receive(repo_path) described_class.new(repo_path).post_receive
end end
end end
end end
...@@ -25,7 +25,7 @@ describe Gitlab::GithubImport::LabelFormatter, lib: true do ...@@ -25,7 +25,7 @@ describe Gitlab::GithubImport::LabelFormatter, lib: true do
context 'when label exists' do context 'when label exists' do
it 'does not create a new label' do it 'does not create a new label' do
project.labels.create(name: raw.name) Labels::CreateService.new(name: raw.name).execute(project: project)
expect { subject.create! }.not_to change(Label, :count) expect { subject.create! }.not_to change(Label, :count)
end end
......
require 'spec_helper'
describe ::Gitlab::RepoPath do
describe '.strip_storage_path' do
before do
allow(Gitlab.config.repositories).to receive(:storages).and_return({
'storage1' => { 'path' => '/foo' },
'storage2' => { 'path' => '/bar' },
})
end
it 'strips the storage path' do
expect(described_class.strip_storage_path('/bar/foo/qux/baz.git')).to eq('foo/qux/baz.git')
end
it 'raises NotFoundError if no storage matches the path' do
expect { described_class.strip_storage_path('/doesnotexist/foo.git') }.to raise_error(
described_class::NotFoundError
)
end
end
end
...@@ -184,18 +184,14 @@ describe Gitlab::Workhorse, lib: true do ...@@ -184,18 +184,14 @@ describe Gitlab::Workhorse, lib: true do
it { expect(subject).to eq({ GL_ID: "user-#{user.id}", RepoPath: repository.path_to_repo }) } it { expect(subject).to eq({ GL_ID: "user-#{user.id}", RepoPath: repository.path_to_repo }) }
context 'when Gitaly socket path is present' do context 'when Gitaly is enabled' do
let(:gitaly_socket_path) { '/tmp/gitaly.sock' }
before do before do
allow(Gitlab.config.gitaly).to receive(:socket_path).and_return(gitaly_socket_path) allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true)
end end
it 'includes Gitaly params in the returned value' do it 'includes Gitaly params in the returned value' do
expect(subject).to include({ gitaly_socket_path = URI(Gitlab::GitalyClient.get_address('default')).path
GitalyResourcePath: "/projects/#{repository.project.id}/git-http/info-refs", expect(subject).to include({ GitalySocketPath: gitaly_socket_path })
GitalySocketPath: gitaly_socket_path,
})
end end
end end
end end
......
...@@ -297,4 +297,40 @@ describe CommitStatus, :models do ...@@ -297,4 +297,40 @@ describe CommitStatus, :models do
end end
end end
end end
describe '#locking_enabled?' do
before do
commit_status.lock_version = 100
end
subject { commit_status.locking_enabled? }
context "when changing status" do
before do
commit_status.status = "running"
end
it "lock" do
is_expected.to be true
end
it "raise exception when trying to update" do
expect{ commit_status.save }.to raise_error(ActiveRecord::StaleObjectError)
end
end
context "when changing description" do
before do
commit_status.description = "test"
end
it "do not lock" do
is_expected.to be false
end
it "save correctly" do
expect(commit_status.save).to be true
end
end
end
end end
...@@ -129,10 +129,10 @@ describe Namespace, models: true do ...@@ -129,10 +129,10 @@ describe Namespace, models: true do
end end
end end
describe '#move_dir' do describe '#move_dir', repository: true do
before do before do
@namespace = create :namespace @namespace = create :namespace
@project = create(:empty_project, namespace: @namespace) @project = create(:project_empty_repo, namespace: @namespace)
allow(@namespace).to receive(:path_changed?).and_return(true) allow(@namespace).to receive(:path_changed?).and_return(true)
end end
...@@ -141,9 +141,9 @@ describe Namespace, models: true do ...@@ -141,9 +141,9 @@ describe Namespace, models: true do
end end
it "moves dir if path changed" do it "moves dir if path changed" do
new_path = @namespace.path + "_new" new_path = @namespace.full_path + "_new"
allow(@namespace).to receive(:path_was).and_return(@namespace.path) allow(@namespace).to receive(:full_path_was).and_return(@namespace.full_path)
allow(@namespace).to receive(:path).and_return(new_path) allow(@namespace).to receive(:full_path).and_return(new_path)
expect(@namespace).to receive(:remove_exports!) expect(@namespace).to receive(:remove_exports!)
expect(@namespace.move_dir).to be_truthy expect(@namespace.move_dir).to be_truthy
end end
...@@ -161,6 +161,31 @@ describe Namespace, models: true do ...@@ -161,6 +161,31 @@ describe Namespace, models: true do
it { expect { @namespace.move_dir }.to raise_error('Namespace cannot be moved, because at least one project has tags in container registry') } it { expect { @namespace.move_dir }.to raise_error('Namespace cannot be moved, because at least one project has tags in container registry') }
end end
context 'renaming a sub-group' do
let(:parent) { create(:group, name: 'parent', path: 'parent') }
let(:child) { create(:group, name: 'child', path: 'child', parent: parent) }
let!(:project) { create(:project_empty_repo, path: 'the-project', namespace: child) }
let(:uploads_dir) { File.join(CarrierWave.root, 'uploads', 'parent') }
let(:pages_dir) { File.join(TestEnv.pages_path, 'parent') }
before do
FileUtils.mkdir_p(File.join(uploads_dir, 'child', 'the-project'))
FileUtils.mkdir_p(File.join(pages_dir, 'child', 'the-project'))
end
it 'correctly moves the repository, uploads and pages' do
expected_repository_path = File.join(TestEnv.repos_path, 'parent', 'renamed', 'the-project.git')
expected_upload_path = File.join(uploads_dir, 'renamed', 'the-project')
expected_pages_path = File.join(pages_dir, 'renamed', 'the-project')
child.update_attributes!(path: 'renamed')
expect(File.directory?(expected_repository_path)).to be(true)
expect(File.directory?(expected_upload_path)).to be(true)
expect(File.directory?(expected_pages_path)).to be(true)
end
end
end end
describe '#actual_size_limit' do describe '#actual_size_limit' do
...@@ -175,14 +200,48 @@ describe Namespace, models: true do ...@@ -175,14 +200,48 @@ describe Namespace, models: true do
end end
end end
describe '#rm_dir', 'callback' do describe '#rm_dir', 'callback', repository: true do
let!(:project) { create(:empty_project, namespace: namespace) } let!(:project) { create(:project_empty_repo, namespace: namespace) }
let!(:path) { File.join(Gitlab.config.repositories.storages.default['path'], namespace.full_path) } let(:repository_storage_path) { Gitlab.config.repositories.storages.default['path'] }
let(:path_in_dir) { File.join(repository_storage_path, namespace.full_path) }
let(:deleted_path) { namespace.full_path.gsub(namespace.path, "#{namespace.full_path}+#{namespace.id}+deleted") }
let(:deleted_path_in_dir) { File.join(repository_storage_path, deleted_path) }
it 'renames its dirs when deleted' do
allow(GitlabShellWorker).to receive(:perform_in)
it "removes its dirs when deleted" do
namespace.destroy namespace.destroy
expect(File.exist?(path)).to be(false) expect(File.exist?(deleted_path_in_dir)).to be(true)
end
it 'schedules the namespace for deletion' do
expect(GitlabShellWorker).to receive(:perform_in).with(5.minutes, :rm_namespace, repository_storage_path, deleted_path)
namespace.destroy
end
context 'in sub-groups' do
let(:parent) { create(:namespace, path: 'parent') }
let(:child) { create(:namespace, parent: parent, path: 'child') }
let!(:project) { create(:project_empty_repo, namespace: child) }
let(:path_in_dir) { File.join(repository_storage_path, 'parent', 'child') }
let(:deleted_path) { File.join('parent', "child+#{child.id}+deleted") }
let(:deleted_path_in_dir) { File.join(repository_storage_path, deleted_path) }
it 'renames its dirs when deleted' do
allow(GitlabShellWorker).to receive(:perform_in)
child.destroy
expect(File.exist?(deleted_path_in_dir)).to be(true)
end
it 'schedules the namespace for deletion' do
expect(GitlabShellWorker).to receive(:perform_in).with(5.minutes, :rm_namespace, repository_storage_path, deleted_path)
child.destroy
end
end end
it 'removes the exports folder' do it 'removes the exports folder' do
......
...@@ -487,12 +487,12 @@ describe API::Internal, api: true do ...@@ -487,12 +487,12 @@ describe API::Internal, api: true do
end end
before do before do
allow(Gitlab.config.gitaly).to receive(:socket_path).and_return('path/to/gitaly.socket') allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true)
end end
it "calls the Gitaly client if it's enabled" do it "calls the Gitaly client if it's enabled" do
expect_any_instance_of(Gitlab::GitalyClient::Notifications). expect_any_instance_of(Gitlab::GitalyClient::Notifications).
to receive(:post_receive).with(project.repository.path) to receive(:post_receive)
post api("/internal/notify_post_receive"), valid_params post api("/internal/notify_post_receive"), valid_params
...@@ -501,7 +501,7 @@ describe API::Internal, api: true do ...@@ -501,7 +501,7 @@ describe API::Internal, api: true do
it "returns 500 if the gitaly call fails" do it "returns 500 if the gitaly call fails" do
expect_any_instance_of(Gitlab::GitalyClient::Notifications). expect_any_instance_of(Gitlab::GitalyClient::Notifications).
to receive(:post_receive).with(project.repository.path).and_raise(GRPC::Unavailable) to receive(:post_receive).and_raise(GRPC::Unavailable)
post api("/internal/notify_post_receive"), valid_params post api("/internal/notify_post_receive"), valid_params
......
...@@ -333,8 +333,16 @@ describe API::Issues, api: true do ...@@ -333,8 +333,16 @@ describe API::Issues, api: true do
end end
let(:base_url) { "/groups/#{group.id}/issues" } let(:base_url) { "/groups/#{group.id}/issues" }
it 'returns all group issues (including opened and closed)' do
get api(base_url, admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(3)
end
it 'returns group issues without confidential issues for non project members' do it 'returns group issues without confidential issues for non project members' do
get api(base_url, non_member) get api("#{base_url}?state=opened", non_member)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -344,7 +352,7 @@ describe API::Issues, api: true do ...@@ -344,7 +352,7 @@ describe API::Issues, api: true do
end end
it 'returns group confidential issues for author' do it 'returns group confidential issues for author' do
get api(base_url, author) get api("#{base_url}?state=opened", author)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -353,7 +361,7 @@ describe API::Issues, api: true do ...@@ -353,7 +361,7 @@ describe API::Issues, api: true do
end end
it 'returns group confidential issues for assignee' do it 'returns group confidential issues for assignee' do
get api(base_url, assignee) get api("#{base_url}?state=opened", assignee)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -362,7 +370,7 @@ describe API::Issues, api: true do ...@@ -362,7 +370,7 @@ describe API::Issues, api: true do
end end
it 'returns group issues with confidential issues for project members' do it 'returns group issues with confidential issues for project members' do
get api(base_url, user) get api("#{base_url}?state=opened", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -371,7 +379,7 @@ describe API::Issues, api: true do ...@@ -371,7 +379,7 @@ describe API::Issues, api: true do
end end
it 'returns group confidential issues for admin' do it 'returns group confidential issues for admin' do
get api(base_url, admin) get api("#{base_url}?state=opened", admin)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -460,7 +468,7 @@ describe API::Issues, api: true do ...@@ -460,7 +468,7 @@ describe API::Issues, api: true do
end end
it 'returns an array of issues in given milestone' do it 'returns an array of issues in given milestone' do
get api("#{base_url}?milestone=#{group_milestone.title}", user) get api("#{base_url}?state=opened&milestone=#{group_milestone.title}", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
......
...@@ -285,8 +285,16 @@ describe API::V3::Issues, api: true do ...@@ -285,8 +285,16 @@ describe API::V3::Issues, api: true do
end end
let(:base_url) { "/groups/#{group.id}/issues" } let(:base_url) { "/groups/#{group.id}/issues" }
it 'returns all group issues (including opened and closed)' do
get v3_api(base_url, admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(3)
end
it 'returns group issues without confidential issues for non project members' do it 'returns group issues without confidential issues for non project members' do
get v3_api(base_url, non_member) get v3_api("#{base_url}?state=opened", non_member)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -295,7 +303,7 @@ describe API::V3::Issues, api: true do ...@@ -295,7 +303,7 @@ describe API::V3::Issues, api: true do
end end
it 'returns group confidential issues for author' do it 'returns group confidential issues for author' do
get v3_api(base_url, author) get v3_api("#{base_url}?state=opened", author)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -303,7 +311,7 @@ describe API::V3::Issues, api: true do ...@@ -303,7 +311,7 @@ describe API::V3::Issues, api: true do
end end
it 'returns group confidential issues for assignee' do it 'returns group confidential issues for assignee' do
get v3_api(base_url, assignee) get v3_api("#{base_url}?state=opened", assignee)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -311,7 +319,7 @@ describe API::V3::Issues, api: true do ...@@ -311,7 +319,7 @@ describe API::V3::Issues, api: true do
end end
it 'returns group issues with confidential issues for project members' do it 'returns group issues with confidential issues for project members' do
get v3_api(base_url, user) get v3_api("#{base_url}?state=opened", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -319,7 +327,7 @@ describe API::V3::Issues, api: true do ...@@ -319,7 +327,7 @@ describe API::V3::Issues, api: true do
end end
it 'returns group confidential issues for admin' do it 'returns group confidential issues for admin' do
get v3_api(base_url, admin) get v3_api("#{base_url}?state=opened", admin)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -368,7 +376,7 @@ describe API::V3::Issues, api: true do ...@@ -368,7 +376,7 @@ describe API::V3::Issues, api: true do
end end
it 'returns an array of issues in given milestone' do it 'returns an array of issues in given milestone' do
get v3_api("#{base_url}?milestone=#{group_milestone.title}", user) get v3_api("#{base_url}?state=opened&milestone=#{group_milestone.title}", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
......
...@@ -18,9 +18,16 @@ describe ChatNames::FindUserService, services: true do ...@@ -18,9 +18,16 @@ describe ChatNames::FindUserService, services: true do
end end
it 'updates when last time chat name was used' do it 'updates when last time chat name was used' do
expect(chat_name.last_used_at).to be_nil
subject subject
expect(chat_name.reload.last_used_at).to be_like_time(Time.now) initial_last_used = chat_name.reload.last_used_at
expect(initial_last_used).to be_present
Timecop.travel(2.days.from_now) { described_class.new(service, params).execute }
expect(chat_name.reload.last_used_at).to be > initial_last_used
end end
end end
......
...@@ -36,6 +36,20 @@ describe Groups::UpdateService, services: true do ...@@ -36,6 +36,20 @@ describe Groups::UpdateService, services: true do
end end
end end
end end
context "with parent_id user doesn't have permissions for" do
let(:service) { described_class.new(public_group, user, parent_id: private_group.id) }
before do
service.execute
end
it 'does not update parent_id' do
updated_group = public_group.reload
expect(updated_group.parent_id).to be_nil
end
end
end end
context 'repository_size_limit assignment as Bytes' do context 'repository_size_limit assignment as Bytes' do
......
require 'spec_helper'
describe Labels::CreateService, services: true do
describe '#execute' do
let(:project) { create(:project) }
let(:group) { create(:group) }
let(:hex_color) { '#FF0000' }
let(:named_color) { 'red' }
let(:upcase_color) { 'RED' }
let(:spaced_color) { ' red ' }
let(:unknown_color) { 'unknown' }
let(:no_color) { '' }
let(:expected_saved_color) { hex_color }
context 'in a project' do
context 'with color in hex-code' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(hex_color)).execute(project: project)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with color in allowed name' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(named_color)).execute(project: project)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with color in up-case allowed name' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(upcase_color)).execute(project: project)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with color surrounded by spaces' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(spaced_color)).execute(project: project)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with unknown color' do
it 'doesn\'t create a label' do
label = Labels::CreateService.new(params_with(unknown_color)).execute(project: project)
expect(label).not_to be_persisted
end
end
context 'with no color' do
it 'doesn\'t create a label' do
label = Labels::CreateService.new(params_with(no_color)).execute(project: project)
expect(label).not_to be_persisted
end
end
end
context 'in a group' do
context 'with color in hex-code' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(hex_color)).execute(group: group)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with color in allowed name' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(named_color)).execute(group: group)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with color in up-case allowed name' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(upcase_color)).execute(group: group)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with color surrounded by spaces' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(spaced_color)).execute(group: group)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with unknown color' do
it 'doesn\'t create a label' do
label = Labels::CreateService.new(params_with(unknown_color)).execute(group: group)
expect(label).not_to be_persisted
end
end
context 'with no color' do
it 'doesn\'t create a label' do
label = Labels::CreateService.new(params_with(no_color)).execute(group: group)
expect(label).not_to be_persisted
end
end
end
context 'in admin area' do
context 'with color in hex-code' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(hex_color)).execute(template: true)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with color in allowed name' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(named_color)).execute(template: true)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with color in up-case allowed name' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(upcase_color)).execute(template: true)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with color surrounded by spaces' do
it 'creates a label' do
label = Labels::CreateService.new(params_with(spaced_color)).execute(template: true)
expect(label).to be_persisted
expect(label.color).to eq expected_saved_color
end
end
context 'with unknown color' do
it 'doesn\'t create a label' do
label = Labels::CreateService.new(params_with(unknown_color)).execute(template: true)
expect(label).not_to be_persisted
end
end
context 'with no color' do
it 'doesn\'t create a label' do
label = Labels::CreateService.new(params_with(no_color)).execute(template: true)
expect(label).not_to be_persisted
end
end
end
end
def params_with(color)
{
title: 'A Label',
color: color
}
end
end
require 'spec_helper'
describe Labels::UpdateService, services: true do
describe '#execute' do
let(:project) { create(:project) }
let(:hex_color) { '#FF0000' }
let(:named_color) { 'red' }
let(:upcase_color) { 'RED' }
let(:spaced_color) { ' red ' }
let(:unknown_color) { 'unknown' }
let(:no_color) { '' }
let(:expected_saved_color) { hex_color }
before(:each) do
@label = Labels::CreateService.new(title: 'Initial', color: '#000000').execute(project: project)
expect(@label).to be_persisted
end
context 'with color in hex-code' do
it 'updates the label' do
label = Labels::UpdateService.new(params_with(hex_color)).execute(@label)
expect(label).to be_valid
expect(label.reload.color).to eq expected_saved_color
end
end
context 'with color in allowed name' do
it 'updates the label' do
label = Labels::UpdateService.new(params_with(named_color)).execute(@label)
expect(label).to be_valid
expect(label.reload.color).to eq expected_saved_color
end
end
context 'with color in up-case allowed name' do
it 'updates the label' do
label = Labels::UpdateService.new(params_with(upcase_color)).execute(@label)
expect(label).to be_valid
expect(label.reload.color).to eq expected_saved_color
end
end
context 'with color surrounded by spaces' do
it 'updates the label' do
label = Labels::UpdateService.new(params_with(spaced_color)).execute(@label)
expect(label).to be_valid
expect(label.reload.color).to eq expected_saved_color
end
end
context 'with unknown color' do
it 'doesn\'t update the label' do
label = Labels::UpdateService.new(params_with(unknown_color)).execute(@label)
expect(label).not_to be_valid
end
end
context 'with no color' do
it 'doesn\'t update the label' do
label = Labels::UpdateService.new(params_with(no_color)).execute(@label)
expect(label).not_to be_valid
end
end
end
def params_with(color)
{
title: 'A Label',
color: color
}
end
end
...@@ -331,6 +331,7 @@ describe SystemNoteService, services: true do ...@@ -331,6 +331,7 @@ describe SystemNoteService, services: true do
subject { described_class.change_branch_presence(noteable, project, author, :source, 'feature', :delete) } subject { described_class.change_branch_presence(noteable, project, author, :source, 'feature', :delete) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
it_behaves_like 'a system note' do it_behaves_like 'a system note' do
let(:action) { 'branch' } let(:action) { 'branch' }
end end
......
RSpec.configure do |config|
config.before(:each, :repository) do
TestEnv.clean_test_path
end
end
...@@ -63,9 +63,6 @@ module TestEnv ...@@ -63,9 +63,6 @@ module TestEnv
clean_test_path clean_test_path
FileUtils.mkdir_p(repos_path)
FileUtils.mkdir_p(backup_path)
# Setup GitLab shell for test instance # Setup GitLab shell for test instance
setup_gitlab_shell setup_gitlab_shell
...@@ -97,10 +94,14 @@ module TestEnv ...@@ -97,10 +94,14 @@ module TestEnv
tmp_test_path = Rails.root.join('tmp', 'tests', '**') tmp_test_path = Rails.root.join('tmp', 'tests', '**')
Dir[tmp_test_path].each do |entry| Dir[tmp_test_path].each do |entry|
unless File.basename(entry) =~ /\Agitlab-(shell|test|test-fork)\z/ unless File.basename(entry) =~ /\Agitlab-(shell|test|test_bare|test-fork|test-fork_bare)\z/
FileUtils.rm_rf(entry) FileUtils.rm_rf(entry)
end end
end end
FileUtils.mkdir_p(repos_path)
FileUtils.mkdir_p(backup_path)
FileUtils.mkdir_p(pages_path)
end end
def setup_gitlab_shell def setup_gitlab_shell
...@@ -153,6 +154,10 @@ module TestEnv ...@@ -153,6 +154,10 @@ module TestEnv
Gitlab.config.backup.path Gitlab.config.backup.path
end end
def pages_path
Gitlab.config.pages.path
end
def copy_forked_repo_with_submodules(project) def copy_forked_repo_with_submodules(project)
base_repo_path = File.expand_path(forked_repo_path_bare) base_repo_path = File.expand_path(forked_repo_path_bare)
target_repo_path = File.expand_path(project.repository_storage_path + "/#{project.full_path}.git") target_repo_path = File.expand_path(project.repository_storage_path + "/#{project.full_path}.git")
......
...@@ -81,6 +81,10 @@ describe 'gitlab:app namespace rake task' do ...@@ -81,6 +81,10 @@ describe 'gitlab:app namespace rake task' do
end # backup_restore task end # backup_restore task
describe 'backup' do describe 'backup' do
before(:all) do
ENV['force'] = 'yes'
end
def tars_glob def tars_glob
Dir.glob(File.join(Gitlab.config.backup.path, '*_gitlab_backup.tar')) Dir.glob(File.join(Gitlab.config.backup.path, '*_gitlab_backup.tar'))
end end
...@@ -88,6 +92,9 @@ describe 'gitlab:app namespace rake task' do ...@@ -88,6 +92,9 @@ describe 'gitlab:app namespace rake task' do
def create_backup def create_backup
FileUtils.rm tars_glob FileUtils.rm tars_glob
# This reconnect makes our project fixture disappear, breaking the restore. Stub it out.
allow(ActiveRecord::Base.connection).to receive(:reconnect!)
# Redirect STDOUT and run the rake task # Redirect STDOUT and run the rake task
orig_stdout = $stdout orig_stdout = $stdout
$stdout = StringIO.new $stdout = StringIO.new
...@@ -119,9 +126,6 @@ describe 'gitlab:app namespace rake task' do ...@@ -119,9 +126,6 @@ describe 'gitlab:app namespace rake task' do
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
FileUtils.touch(File.join(path, "dummy.txt")) FileUtils.touch(File.join(path, "dummy.txt"))
# We need to use the full path instead of the relative one
allow(Gitlab.config.gitlab_shell).to receive(:path).and_return(File.expand_path(Gitlab.config.gitlab_shell.path, Rails.root.to_s))
ENV["SKIP"] = "db" ENV["SKIP"] = "db"
create_backup create_backup
end end
...@@ -227,8 +231,8 @@ describe 'gitlab:app namespace rake task' do ...@@ -227,8 +231,8 @@ describe 'gitlab:app namespace rake task' do
FileUtils.mkdir('tmp/tests/default_storage') FileUtils.mkdir('tmp/tests/default_storage')
FileUtils.mkdir('tmp/tests/custom_storage') FileUtils.mkdir('tmp/tests/custom_storage')
storages = { storages = {
'default' => { 'path' => 'tmp/tests/default_storage' }, 'default' => { 'path' => Settings.absolute('tmp/tests/default_storage') },
'custom' => { 'path' => 'tmp/tests/custom_storage' } 'custom' => { 'path' => Settings.absolute('tmp/tests/custom_storage') }
} }
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
......
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