Commit 4d2d744a authored by Phil Hughes's avatar Phil Hughes

Merge branch 'master' into enable-new-navigaton-by-default

parents 25a3b7fa f7c8434c
...@@ -606,6 +606,18 @@ Style/YodaCondition: ...@@ -606,6 +606,18 @@ Style/YodaCondition:
Style/Proc: Style/Proc:
Enabled: true Enabled: true
# Use `spam?` instead of `is_spam?`
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
Style/PredicateName:
Enabled: true
NamePrefixBlacklist: is_
Exclude:
- 'spec/**/*'
- 'features/**/*'
# Metrics ##################################################################### # Metrics #####################################################################
# A calculated magnitude based on number of assignments, # A calculated magnitude based on number of assignments,
...@@ -631,7 +643,7 @@ Metrics/ClassLength: ...@@ -631,7 +643,7 @@ Metrics/ClassLength:
# of test cases needed to validate a method. # of test cases needed to validate a method.
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:
Enabled: true Enabled: true
Max: 16 Max: 15
# Limit lines to 80 characters. # Limit lines to 80 characters.
Metrics/LineLength: Metrics/LineLength:
......
...@@ -237,14 +237,6 @@ Style/PercentLiteralDelimiters: ...@@ -237,14 +237,6 @@ Style/PercentLiteralDelimiters:
Style/PerlBackrefs: Style/PerlBackrefs:
Enabled: false Enabled: false
# Offense count: 105
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
Style/PredicateName:
Enabled: false
# Offense count: 58 # Offense count: 58
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
......
...@@ -164,7 +164,7 @@ Assigning a team label makes sure issues get the attention of the appropriate ...@@ -164,7 +164,7 @@ Assigning a team label makes sure issues get the attention of the appropriate
people. people.
The current team labels are ~Build, ~CI, ~Discussion, ~Documentation, ~Edge, The current team labels are ~Build, ~CI, ~Discussion, ~Documentation, ~Edge,
~Gitaly, ~Platform, ~Prometheus, ~Release, and ~"UX". ~Geo, ~Gitaly, ~Platform, ~Prometheus, ~Release, and ~"UX".
The descriptions on the [labels page][labels-page] explain what falls under the The descriptions on the [labels page][labels-page] explain what falls under the
responsibility of each team. responsibility of each team.
......
...@@ -284,7 +284,7 @@ group :metrics do ...@@ -284,7 +284,7 @@ group :metrics do
gem 'influxdb', '~> 0.2', require: false gem 'influxdb', '~> 0.2', require: false
# Prometheus # Prometheus
gem 'prometheus-client-mmap', '~>0.7.0.beta12' gem 'prometheus-client-mmap', '~>0.7.0.beta14'
gem 'raindrops', '~> 0.18' gem 'raindrops', '~> 0.18'
end end
......
...@@ -619,7 +619,7 @@ GEM ...@@ -619,7 +619,7 @@ GEM
parser parser
unparser unparser
procto (0.0.3) procto (0.0.3)
prometheus-client-mmap (0.7.0.beta12) prometheus-client-mmap (0.7.0.beta14)
mmap2 (~> 2.2, >= 2.2.7) mmap2 (~> 2.2, >= 2.2.7)
pry (0.10.4) pry (0.10.4)
coderay (~> 1.1.0) coderay (~> 1.1.0)
...@@ -1093,7 +1093,7 @@ DEPENDENCIES ...@@ -1093,7 +1093,7 @@ DEPENDENCIES
pg (~> 0.18.2) pg (~> 0.18.2)
poltergeist (~> 1.9.0) poltergeist (~> 1.9.0)
premailer-rails (~> 1.9.7) premailer-rails (~> 1.9.7)
prometheus-client-mmap (~> 0.7.0.beta12) prometheus-client-mmap (~> 0.7.0.beta14)
pry-byebug (~> 3.4.1) pry-byebug (~> 3.4.1)
pry-rails (~> 0.3.4) pry-rails (~> 0.3.4)
rack-attack (~> 4.4.1) rack-attack (~> 4.4.1)
......
...@@ -85,6 +85,13 @@ class DropDown { ...@@ -85,6 +85,13 @@ class DropDown {
const renderableList = this.list.querySelector('ul[data-dynamic]') || this.list; const renderableList = this.list.querySelector('ul[data-dynamic]') || this.list;
renderableList.innerHTML = children.join(''); renderableList.innerHTML = children.join('');
const listEvent = new CustomEvent('render.dl', {
detail: {
list: this,
},
});
this.list.dispatchEvent(listEvent);
} }
renderChildren(data) { renderChildren(data) {
......
/* global Flash */
import Ajax from '~/droplab/plugins/ajax';
import Filter from '~/droplab/plugins/filter';
import './filtered_search_dropdown';
class DropdownEmoji extends gl.FilteredSearchDropdown {
constructor(options = {}) {
super(options);
this.config = {
Ajax: {
endpoint: `${gon.relative_url_root || ''}/autocomplete/award_emojis`,
method: 'setData',
loadingTemplate: this.loadingTemplate,
onError() {
/* eslint-disable no-new */
new Flash('An error occured fetching the dropdown data.');
/* eslint-enable no-new */
},
},
Filter: {
template: 'name',
},
};
import(/* webpackChunkName: 'emoji' */ '~/emoji')
.then(({ glEmojiTag }) => { this.glEmojiTag = glEmojiTag; })
.catch(() => { /* ignore error and leave emoji name in the search bar */ });
this.unbindEvents();
this.bindEvents();
}
bindEvents() {
super.bindEvents();
this.listRenderedWrapper = this.listRendered.bind(this);
this.dropdown.addEventListener('render.dl', this.listRenderedWrapper);
}
unbindEvents() {
this.dropdown.removeEventListener('render.dl', this.listRenderedWrapper);
super.unbindEvents();
}
listRendered() {
this.replaceEmojiElement();
}
itemClicked(e) {
super.itemClicked(e, (selected) => {
const name = selected.querySelector('.js-data-value').innerText.trim();
return gl.DropdownUtils.getEscapedText(name);
});
}
renderContent(forceShowList = false) {
this.droplab.changeHookList(this.hookId, this.dropdown, [Ajax, Filter], this.config);
super.renderContent(forceShowList);
}
replaceEmojiElement() {
if (!this.glEmojiTag) return;
// Replace empty gl-emoji tag to real content
const dropdownItems = [...this.dropdown.querySelectorAll('.filter-dropdown-item')];
dropdownItems.forEach((dropdownItem) => {
const name = dropdownItem.querySelector('.js-data-value').innerText;
const emojiTag = this.glEmojiTag(name);
const emojiElement = dropdownItem.querySelector('gl-emoji');
emojiElement.outerHTML = emojiTag;
});
}
init() {
this.droplab
.addHook(this.input, this.dropdown, [Ajax, Filter], this.config).init();
}
}
window.gl = window.gl || {};
gl.DropdownEmoji = DropdownEmoji;
...@@ -61,7 +61,7 @@ class DropdownHint extends gl.FilteredSearchDropdown { ...@@ -61,7 +61,7 @@ class DropdownHint extends gl.FilteredSearchDropdown {
.map(tokenKey => ({ .map(tokenKey => ({
icon: `fa-${tokenKey.icon}`, icon: `fa-${tokenKey.icon}`,
hint: tokenKey.key, hint: tokenKey.key,
tag: `<${tokenKey.symbol}${tokenKey.key}>`, tag: `<${tokenKey.tag}>`,
type: tokenKey.type, type: tokenKey.type,
})); }));
......
import './dropdown_emoji';
import './dropdown_hint'; import './dropdown_hint';
import './dropdown_non_user'; import './dropdown_non_user';
import './dropdown_user'; import './dropdown_user';
......
...@@ -58,6 +58,11 @@ class FilteredSearchDropdownManager { ...@@ -58,6 +58,11 @@ class FilteredSearchDropdownManager {
}, },
element: this.container.querySelector('#js-dropdown-label'), element: this.container.querySelector('#js-dropdown-label'),
}, },
'my-reaction': {
reference: null,
gl: 'DropdownEmoji',
element: this.container.querySelector('#js-dropdown-my-reaction'),
},
hint: { hint: {
reference: null, reference: null,
gl: 'DropdownHint', gl: 'DropdownHint',
......
...@@ -439,8 +439,13 @@ class FilteredSearchManager { ...@@ -439,8 +439,13 @@ class FilteredSearchManager {
const match = this.filteredSearchTokenKeys.searchByKeyParam(keyParam); const match = this.filteredSearchTokenKeys.searchByKeyParam(keyParam);
if (match) { if (match) {
const indexOf = keyParam.indexOf('_'); // Use lastIndexOf because the token key is allowed to contain underscore
const sanitizedKey = indexOf !== -1 ? keyParam.slice(0, keyParam.indexOf('_')) : keyParam; // e.g. 'my_reaction' is the token key of 'my_reaction_emoji'
const lastIndexOf = keyParam.lastIndexOf('_');
let sanitizedKey = lastIndexOf !== -1 ? keyParam.slice(0, lastIndexOf) : keyParam;
// Replace underscore with hyphen in the sanitizedkey.
// e.g. 'my_reaction' => 'my-reaction'
sanitizedKey = sanitizedKey.replace('_', '-');
const symbol = match.symbol; const symbol = match.symbol;
let quotationsToUse = ''; let quotationsToUse = '';
...@@ -515,7 +520,10 @@ class FilteredSearchManager { ...@@ -515,7 +520,10 @@ class FilteredSearchManager {
const condition = this.filteredSearchTokenKeys const condition = this.filteredSearchTokenKeys
.searchByConditionKeyValue(token.key, token.value.toLowerCase()); .searchByConditionKeyValue(token.key, token.value.toLowerCase());
const { param } = this.filteredSearchTokenKeys.searchByKey(token.key) || {}; const { param } = this.filteredSearchTokenKeys.searchByKey(token.key) || {};
const keyParam = param ? `${token.key}_${param}` : token.key; // Replace hyphen with underscore to use as request parameter
// e.g. 'my-reaction' => 'my_reaction'
const underscoredKey = token.key.replace('-', '_');
const keyParam = param ? `${underscoredKey}_${param}` : underscoredKey;
let tokenPath = ''; let tokenPath = '';
if (condition) { if (condition) {
......
...@@ -4,26 +4,42 @@ const tokenKeys = [{ ...@@ -4,26 +4,42 @@ const tokenKeys = [{
param: 'username', param: 'username',
symbol: '@', symbol: '@',
icon: 'pencil', icon: 'pencil',
tag: '@author',
}, { }, {
key: 'assignee', key: 'assignee',
type: 'string', type: 'string',
param: 'username', param: 'username',
symbol: '@', symbol: '@',
icon: 'user', icon: 'user',
tag: '@assignee',
}, { }, {
key: 'milestone', key: 'milestone',
type: 'string', type: 'string',
param: 'title', param: 'title',
symbol: '%', symbol: '%',
icon: 'clock-o', icon: 'clock-o',
tag: '%milestone',
}, { }, {
key: 'label', key: 'label',
type: 'array', type: 'array',
param: 'name[]', param: 'name[]',
symbol: '~', symbol: '~',
icon: 'tag', icon: 'tag',
tag: '~label',
}]; }];
if (gon.current_user_id) {
// Appending tokenkeys only logged-in
tokenKeys.push({
key: 'my-reaction',
type: 'string',
param: 'emoji',
symbol: '',
icon: 'thumbs-up',
tag: 'emoji',
});
}
const alternativeTokenKeys = [{ const alternativeTokenKeys = [{
key: 'label', key: 'label',
type: 'string', type: 'string',
...@@ -84,6 +100,10 @@ class FilteredSearchTokenKeys { ...@@ -84,6 +100,10 @@ class FilteredSearchTokenKeys {
return tokenKeysWithAlternative.find((tokenKey) => { return tokenKeysWithAlternative.find((tokenKey) => {
let tokenKeyParam = tokenKey.key; let tokenKeyParam = tokenKey.key;
// Replace hyphen with underscore to compare keyParam with tokenKeyParam
// e.g. 'my-reaction' => 'my_reaction'
tokenKeyParam = tokenKeyParam.replace('-', '_');
if (tokenKey.param) { if (tokenKey.param) {
tokenKeyParam += `_${tokenKey.param}`; tokenKeyParam += `_${tokenKey.param}`;
} }
......
...@@ -132,6 +132,23 @@ class FilteredSearchVisualTokens { ...@@ -132,6 +132,23 @@ class FilteredSearchVisualTokens {
.catch(() => { }); .catch(() => { });
} }
static updateEmojiTokenAppearance(tokenValueContainer, tokenValueElement, tokenValue) {
const container = tokenValueContainer;
const element = tokenValueElement;
return import(/* webpackChunkName: 'emoji' */ '../emoji')
.then((Emoji) => {
if (!Emoji.isEmojiNameValid(tokenValue)) {
return;
}
container.dataset.originalValue = tokenValue;
element.innerHTML = Emoji.glEmojiTag(tokenValue);
})
// ignore error and leave emoji name in the search bar
.catch(() => { });
}
static renderVisualTokenValue(parentElement, tokenName, tokenValue) { static renderVisualTokenValue(parentElement, tokenName, tokenValue) {
const tokenValueContainer = parentElement.querySelector('.value-container'); const tokenValueContainer = parentElement.querySelector('.value-container');
const tokenValueElement = tokenValueContainer.querySelector('.value'); const tokenValueElement = tokenValueContainer.querySelector('.value');
...@@ -144,6 +161,10 @@ class FilteredSearchVisualTokens { ...@@ -144,6 +161,10 @@ class FilteredSearchVisualTokens {
FilteredSearchVisualTokens.updateUserTokenAppearance( FilteredSearchVisualTokens.updateUserTokenAppearance(
tokenValueContainer, tokenValueElement, tokenValue, tokenValueContainer, tokenValueElement, tokenValue,
); );
} else if (tokenType === 'my-reaction') {
FilteredSearchVisualTokens.updateEmojiTokenAppearance(
tokenValueContainer, tokenValueElement, tokenValue,
);
} }
} }
......
<script> <script>
import identicon from '../../vue_shared/components/identicon.vue';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import groupIdenticon from './group_identicon.vue';
export default { export default {
components: { components: {
groupIdenticon, identicon,
}, },
props: { props: {
group: { group: {
...@@ -205,7 +205,7 @@ export default { ...@@ -205,7 +205,7 @@ export default {
class="avatar s40" class="avatar s40"
:src="group.avatarUrl" :src="group.avatarUrl"
/> />
<group-identicon <identicon
v-else v-else
:entity-id=group.id :entity-id=group.id
:entity-name="group.name" :entity-name="group.name"
......
export const isSticky = (el, scrollY, stickyTop) => { export const isSticky = (el, scrollY, stickyTop) => {
const top = el.offsetTop - scrollY; const top = Math.floor(el.offsetTop - scrollY);
if (top <= stickyTop) { if (top <= stickyTop) {
el.classList.add('is-stuck'); el.classList.add('is-stuck');
......
...@@ -253,6 +253,7 @@ import bp from './breakpoints'; ...@@ -253,6 +253,7 @@ import bp from './breakpoints';
loadDiff(source) { loadDiff(source) {
if (this.diffsLoaded) { if (this.diffsLoaded) {
document.dispatchEvent(new CustomEvent('scroll'));
return; return;
} }
......
...@@ -47,7 +47,6 @@ export default class NewNavSidebar { ...@@ -47,7 +47,6 @@ export default class NewNavSidebar {
if (this.$sidebar.length) { if (this.$sidebar.length) {
this.$sidebar.toggleClass('sidebar-icons-only', collapsed); this.$sidebar.toggleClass('sidebar-icons-only', collapsed);
this.$page.toggleClass('page-with-new-sidebar', !collapsed);
this.$page.toggleClass('page-with-icon-sidebar', breakpoint === 'sm' ? true : collapsed); this.$page.toggleClass('page-with-icon-sidebar', breakpoint === 'sm' ? true : collapsed);
} }
NewNavSidebar.setCollapsedCookie(collapsed); NewNavSidebar.setCollapsedCookie(collapsed);
......
<script> <script>
export default { export default {
name: 'PipelineNavigationTabs', name: 'PipelineNavigationTabs',
props: { props: {
scope: { scope: {
...@@ -18,6 +18,12 @@ export default { ...@@ -18,6 +18,12 @@ export default {
mounted() { mounted() {
$(document).trigger('init.scrolling-tabs'); $(document).trigger('init.scrolling-tabs');
}, },
methods: {
shouldRenderBadge(count) {
// 0 is valid in a badge, but evaluates to false, we need to check for undefined
return count !== undefined;
},
},
}; };
</script> </script>
<template> <template>
...@@ -27,7 +33,9 @@ export default { ...@@ -27,7 +33,9 @@ export default {
:class="{ active: scope === 'all'}"> :class="{ active: scope === 'all'}">
<a :href="paths.allPath"> <a :href="paths.allPath">
All All
<span class="badge js-totalbuilds-count"> <span
v-if="shouldRenderBadge(count.all)"
class="badge js-totalbuilds-count">
{{count.all}} {{count.all}}
</span> </span>
</a> </a>
...@@ -37,7 +45,9 @@ export default { ...@@ -37,7 +45,9 @@ export default {
:class="{ active: scope === 'pending'}"> :class="{ active: scope === 'pending'}">
<a :href="paths.pendingPath"> <a :href="paths.pendingPath">
Pending Pending
<span class="badge"> <span
v-if="shouldRenderBadge(count.pending)"
class="badge">
{{count.pending}} {{count.pending}}
</span> </span>
</a> </a>
...@@ -47,7 +57,9 @@ export default { ...@@ -47,7 +57,9 @@ export default {
:class="{ active: scope === 'running'}"> :class="{ active: scope === 'running'}">
<a :href="paths.runningPath"> <a :href="paths.runningPath">
Running Running
<span class="badge"> <span
v-if="shouldRenderBadge(count.running)"
class="badge">
{{count.running}} {{count.running}}
</span> </span>
</a> </a>
...@@ -57,7 +69,9 @@ export default { ...@@ -57,7 +69,9 @@ export default {
:class="{ active: scope === 'finished'}"> :class="{ active: scope === 'finished'}">
<a :href="paths.finishedPath"> <a :href="paths.finishedPath">
Finished Finished
<span class="badge"> <span
v-if="shouldRenderBadge(count.finished)"
class="badge">
{{count.finished}} {{count.finished}}
</span> </span>
</a> </a>
......
...@@ -139,7 +139,9 @@ ...@@ -139,7 +139,9 @@
}; };
</script> </script>
<template> <template>
<div :class="cssClass"> <div
class="pipelines-container"
:class="cssClass">
<div <div
class="top-area scrolling-tabs-container inner-page-scroll-tabs" class="top-area scrolling-tabs-container inner-page-scroll-tabs"
v-if="!isLoading && !shouldRenderEmptyState"> v-if="!isLoading && !shouldRenderEmptyState">
......
...@@ -771,6 +771,11 @@ ...@@ -771,6 +771,11 @@
&::before { &::before {
top: 16px; top: 16px;
} }
&.dropdown-menu-user-link::before {
top: 50%;
transform: translateY(-50%);
}
} }
} }
} }
......
...@@ -225,6 +225,18 @@ ...@@ -225,6 +225,18 @@
color: $common-gray-dark; color: $common-gray-dark;
} }
gl-emoji {
display: inline-block;
font-family: inherit;
font-size: inherit;
vertical-align: inherit;
img {
height: 18px;
width: 18px;
}
}
.form-control { .form-control {
position: relative; position: relative;
min-width: 200px; min-width: 200px;
...@@ -277,7 +289,7 @@ ...@@ -277,7 +289,7 @@
} }
.filtered-search-input-dropdown-menu { .filtered-search-input-dropdown-menu {
max-height: 225px; max-height: 260px;
max-width: 280px; max-width: 280px;
overflow: auto; overflow: auto;
...@@ -478,3 +490,7 @@ ...@@ -478,3 +490,7 @@
padding: 8px 16px; padding: 8px 16px;
text-align: center; text-align: center;
} }
.issues-details-filters {
@include new-style-dropdown;
}
...@@ -268,6 +268,7 @@ ...@@ -268,6 +268,7 @@
// TODO: change global style // TODO: change global style
.ajax-project-dropdown, .ajax-project-dropdown,
body[data-page="projects:blob:new"] #select2-drop, body[data-page="projects:blob:new"] #select2-drop,
body[data-page="profiles:show"] #select2-drop,
body[data-page="projects:blob:edit"] #select2-drop { body[data-page="projects:blob:edit"] #select2-drop {
&.select2-drop { &.select2-drop {
color: $gl-text-color; color: $gl-text-color;
......
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
color: $md-link-color; color: $md-link-color;
} }
img { img:not(.emoji) {
/*max-width: 100%;*/
margin: 0 0 8px; margin: 0 0 8px;
} }
...@@ -26,6 +25,7 @@ ...@@ -26,6 +25,7 @@
min-width: inherit; min-width: inherit;
min-height: inherit; min-height: inherit;
background-color: inherit; background-color: inherit;
max-width: 100%;
} }
p a:not(.no-attachment-icon) img { p a:not(.no-attachment-icon) img {
......
...@@ -204,6 +204,8 @@ ...@@ -204,6 +204,8 @@
.gitlab-ci-yml-selector, .gitlab-ci-yml-selector,
.dockerfile-selector, .dockerfile-selector,
.template-type-selector { .template-type-selector {
@include new-style-dropdown;
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
font-family: $regular_font; font-family: $regular_font;
......
...@@ -14,3 +14,7 @@ ...@@ -14,3 +14,7 @@
font-size: 18px; font-size: 18px;
} }
} }
.notification-form {
@include new-style-dropdown;
}
...@@ -927,3 +927,7 @@ button.mini-pipeline-graph-dropdown-toggle { ...@@ -927,3 +927,7 @@ button.mini-pipeline-graph-dropdown-toggle {
} }
} }
} }
.pipelines-container .top-area .nav-controls > .btn:last-child {
float: none;
}
class AutocompleteController < ApplicationController class AutocompleteController < ApplicationController
skip_before_action :authenticate_user!, only: [:users] AWARD_EMOJI_MAX = 100
skip_before_action :authenticate_user!, only: [:users, :award_emojis]
before_action :load_project, only: [:users] before_action :load_project, only: [:users]
before_action :find_users, only: [:users] before_action :find_users, only: [:users]
...@@ -48,6 +50,20 @@ class AutocompleteController < ApplicationController ...@@ -48,6 +50,20 @@ class AutocompleteController < ApplicationController
render json: projects.to_json(only: [:id, :name_with_namespace], methods: :name_with_namespace) render json: projects.to_json(only: [:id, :name_with_namespace], methods: :name_with_namespace)
end end
def award_emojis
emoji_with_count = AwardEmoji
.limit(AWARD_EMOJI_MAX)
.where(user: current_user)
.group(:name)
.order('count_all DESC, name ASC')
.count
# Transform from hash to array to guarantee json order
# e.g. { 'thumbsup' => 2, 'thumbsdown' = 1 }
# => [{ name: 'thumbsup' }, { name: 'thumbsdown' }]
render json: emoji_with_count.map { |k, v| { name: k } }
end
private private
def find_users def find_users
......
...@@ -15,7 +15,17 @@ module IssuableCollections ...@@ -15,7 +15,17 @@ module IssuableCollections
end end
def merge_requests_collection def merge_requests_collection
merge_requests_finder.execute.preload(:source_project, :target_project, :author, :assignee, :labels, :milestone, :head_pipeline, target_project: :namespace, merge_request_diff: :merge_request_diff_commits) merge_requests_finder.execute.preload(
:source_project,
:target_project,
:author,
:assignee,
:labels,
:milestone,
head_pipeline: :project,
target_project: :namespace,
merge_request_diff: :merge_request_diff_commits
)
end end
def issues_finder def issues_finder
......
...@@ -35,13 +35,13 @@ class Groups::MilestonesController < Groups::ApplicationController ...@@ -35,13 +35,13 @@ class Groups::MilestonesController < Groups::ApplicationController
end end
def edit def edit
render_404 if @milestone.is_legacy_group_milestone? render_404 if @milestone.legacy_group_milestone?
end end
def update def update
# Keep this compatible with legacy group milestones where we have to update # Keep this compatible with legacy group milestones where we have to update
# all projects milestones states at once. # all projects milestones states at once.
if @milestone.is_legacy_group_milestone? if @milestone.legacy_group_milestone?
update_params = milestone_params.select { |key| key == "state_event" } update_params = milestone_params.select { |key| key == "state_event" }
milestones = @milestone.milestones milestones = @milestone.milestones
else else
...@@ -67,7 +67,7 @@ class Groups::MilestonesController < Groups::ApplicationController ...@@ -67,7 +67,7 @@ class Groups::MilestonesController < Groups::ApplicationController
end end
def milestone_path def milestone_path
if @milestone.is_legacy_group_milestone? if @milestone.legacy_group_milestone?
group_milestone_path(group, @milestone.safe_title, title: @milestone.title) group_milestone_path(group, @milestone.safe_title, title: @milestone.title)
else else
group_milestone_path(group, @milestone.iid) group_milestone_path(group, @milestone.iid)
......
...@@ -202,7 +202,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -202,7 +202,7 @@ class Projects::IssuesController < Projects::ApplicationController
task_status: @issue.task_status task_status: @issue.task_status
} }
if @issue.is_edited? if @issue.edited?
response[:updated_at] = @issue.updated_at response[:updated_at] = @issue.updated_at
response[:updated_by_name] = @issue.last_edited_by.name response[:updated_by_name] = @issue.last_edited_by.name
response[:updated_by_path] = user_path(@issue.last_edited_by) response[:updated_by_path] = user_path(@issue.last_edited_by)
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# sort: string # sort: string
# non_archived: boolean # non_archived: boolean
# iids: integer[] # iids: integer[]
# my_reaction_emoji: string
# #
class IssuableFinder class IssuableFinder
include CreatedAtFilter include CreatedAtFilter
...@@ -46,6 +47,7 @@ class IssuableFinder ...@@ -46,6 +47,7 @@ class IssuableFinder
items = by_iids(items) items = by_iids(items)
items = by_milestone(items) items = by_milestone(items)
items = by_label(items) items = by_label(items)
items = by_my_reaction_emoji(items)
# Filtering by project HAS TO be the last because we use the project IDs yielded by the issuable query thus far # Filtering by project HAS TO be the last because we use the project IDs yielded by the issuable query thus far
items = by_project(items) items = by_project(items)
...@@ -371,6 +373,14 @@ class IssuableFinder ...@@ -371,6 +373,14 @@ class IssuableFinder
items items
end end
def by_my_reaction_emoji(items)
if params[:my_reaction_emoji].present? && current_user
items = items.awarded(current_user, params[:my_reaction_emoji])
end
items
end
def by_due_date(items) def by_due_date(items)
if due_date? if due_date?
if filter_by_no_due_date? if filter_by_no_due_date?
......
...@@ -178,7 +178,7 @@ module ApplicationHelper ...@@ -178,7 +178,7 @@ module ApplicationHelper
end end
def edited_time_ago_with_tooltip(object, placement: 'top', html_class: 'time_ago', exclude_author: false) def edited_time_ago_with_tooltip(object, placement: 'top', html_class: 'time_ago', exclude_author: false)
return unless object.is_edited? return unless object.edited?
content_tag :small, class: 'edited-text' do content_tag :small, class: 'edited-text' do
output = content_tag(:span, 'Edited ') output = content_tag(:span, 'Edited ')
......
...@@ -229,7 +229,7 @@ module IssuablesHelper ...@@ -229,7 +229,7 @@ module IssuablesHelper
end end
def updated_at_by(issuable) def updated_at_by(issuable)
return {} unless issuable.is_edited? return {} unless issuable.edited?
{ {
updatedAt: issuable.updated_at.to_time.iso8601, updatedAt: issuable.updated_at.to_time.iso8601,
......
...@@ -164,7 +164,7 @@ module MilestonesHelper ...@@ -164,7 +164,7 @@ module MilestonesHelper
def group_milestone_route(milestone, params = {}) def group_milestone_route(milestone, params = {})
params = nil if params.empty? params = nil if params.empty?
if milestone.is_legacy_group_milestone? if milestone.legacy_group_milestone?
group_milestone_path(@group, milestone.safe_title, title: milestone.title, milestone: params) group_milestone_path(@group, milestone.safe_title, title: milestone.title, milestone: params)
else else
group_milestone_path(@group, milestone.iid, milestone: params) group_milestone_path(@group, milestone.iid, milestone: params)
......
module MilestonesRoutingHelper module MilestonesRoutingHelper
def milestone_path(milestone, *args) def milestone_path(milestone, *args)
if milestone.is_group_milestone? if milestone.group_milestone?
group_milestone_path(milestone.group, milestone, *args) group_milestone_path(milestone.group, milestone, *args)
elsif milestone.is_project_milestone? elsif milestone.project_milestone?
project_milestone_path(milestone.project, milestone, *args) project_milestone_path(milestone.project, milestone, *args)
end end
end end
def milestone_url(milestone, *args) def milestone_url(milestone, *args)
if milestone.is_group_milestone? if milestone.group_milestone?
group_milestone_url(milestone.group, milestone, *args) group_milestone_url(milestone.group, milestone, *args)
elsif milestone.is_project_milestone? elsif milestone.project_milestone?
project_milestone_url(milestone.project, milestone, *args) project_milestone_url(milestone.project, milestone, *args)
end end
end end
......
...@@ -142,7 +142,7 @@ module Ci ...@@ -142,7 +142,7 @@ module Ci
expire: RUNNER_QUEUE_EXPIRY_TIME, overwrite: false) expire: RUNNER_QUEUE_EXPIRY_TIME, overwrite: false)
end end
def is_runner_queue_value_latest?(value) def runner_queue_value_latest?(value)
ensure_runner_queue_value == value if value.present? ensure_runner_queue_value == value if value.present?
end end
......
...@@ -11,6 +11,21 @@ module Awardable ...@@ -11,6 +11,21 @@ module Awardable
end end
module ClassMethods module ClassMethods
def awarded(user, name)
sql = <<~EOL
EXISTS (
SELECT TRUE
FROM award_emoji
WHERE user_id = :user_id AND
name = :name AND
awardable_type = :awardable_type AND
awardable_id = #{self.arel_table.name}.id
)
EOL
where(sql, user_id: user.id, name: name, awardable_type: self.name)
end
def order_upvotes_desc def order_upvotes_desc
order_votes_desc(AwardEmoji::UPVOTE_NAME) order_votes_desc(AwardEmoji::UPVOTE_NAME)
end end
......
module Editable module Editable
extend ActiveSupport::Concern extend ActiveSupport::Concern
def is_edited? def edited?
last_edited_at.present? && last_edited_at != created_at last_edited_at.present? && last_edited_at != created_at
end end
......
...@@ -70,19 +70,19 @@ module Milestoneish ...@@ -70,19 +70,19 @@ module Milestoneish
due_date && due_date.past? due_date && due_date.past?
end end
def is_group_milestone? def group_milestone?
false false
end end
def is_project_milestone? def project_milestone?
false false
end end
def is_legacy_group_milestone? def legacy_group_milestone?
false false
end end
def is_dashboard_milestone? def dashboard_milestone?
false false
end end
......
...@@ -3,7 +3,7 @@ class DashboardMilestone < GlobalMilestone ...@@ -3,7 +3,7 @@ class DashboardMilestone < GlobalMilestone
{ authorized_only: true } { authorized_only: true }
end end
def is_dashboard_milestone? def dashboard_milestone?
true true
end end
end end
...@@ -49,7 +49,7 @@ class Deployment < ActiveRecord::Base ...@@ -49,7 +49,7 @@ class Deployment < ActiveRecord::Base
# created before then could have a `sha` referring to a commit that no # created before then could have a `sha` referring to a commit that no
# longer exists in the repository, so just ignore those. # longer exists in the repository, so just ignore those.
begin begin
project.repository.is_ancestor?(commit.id, sha) project.repository.ancestor?(commit.id, sha)
rescue Rugged::OdbError rescue Rugged::OdbError
false false
end end
......
...@@ -17,7 +17,7 @@ class GroupMilestone < GlobalMilestone ...@@ -17,7 +17,7 @@ class GroupMilestone < GlobalMilestone
{ group_id: group.id } { group_id: group.id }
end end
def is_legacy_group_milestone? def legacy_group_milestone?
true true
end end
end end
...@@ -163,7 +163,7 @@ class Milestone < ActiveRecord::Base ...@@ -163,7 +163,7 @@ class Milestone < ActiveRecord::Base
# Milestone.first.to_reference(same_namespace_project) # => "gitlab-ce%1" # Milestone.first.to_reference(same_namespace_project) # => "gitlab-ce%1"
# #
def to_reference(from_project = nil, format: :iid, full: false) def to_reference(from_project = nil, format: :iid, full: false)
return if is_group_milestone? && format != :name return if group_milestone? && format != :name
format_reference = milestone_format_reference(format) format_reference = milestone_format_reference(format)
reference = "#{self.class.reference_prefix}#{format_reference}" reference = "#{self.class.reference_prefix}#{format_reference}"
...@@ -207,11 +207,11 @@ class Milestone < ActiveRecord::Base ...@@ -207,11 +207,11 @@ class Milestone < ActiveRecord::Base
group || project group || project
end end
def is_group_milestone? def group_milestone?
group_id.present? group_id.present?
end end
def is_project_milestone? def project_milestone?
project_id.present? project_id.present?
end end
......
...@@ -152,14 +152,14 @@ module Network ...@@ -152,14 +152,14 @@ module Network
end end
def find_free_parent_space(range, space_base, space_step, space_default) def find_free_parent_space(range, space_base, space_step, space_default)
if is_overlap?(range, space_default) if overlap?(range, space_default)
find_free_space(range, space_step, space_base, space_default) find_free_space(range, space_step, space_base, space_default)
else else
space_default space_default
end end
end end
def is_overlap?(range, overlap_space) def overlap?(range, overlap_space)
range.each do |i| range.each do |i|
if i != range.first && if i != range.first &&
i != range.last && i != range.last &&
......
...@@ -101,9 +101,9 @@ class ChatNotificationService < Service ...@@ -101,9 +101,9 @@ class ChatNotificationService < Service
when "push", "tag_push" when "push", "tag_push"
ChatMessage::PushMessage.new(data) ChatMessage::PushMessage.new(data)
when "issue" when "issue"
ChatMessage::IssueMessage.new(data) unless is_update?(data) ChatMessage::IssueMessage.new(data) unless update?(data)
when "merge_request" when "merge_request"
ChatMessage::MergeMessage.new(data) unless is_update?(data) ChatMessage::MergeMessage.new(data) unless update?(data)
when "note" when "note"
ChatMessage::NoteMessage.new(data) ChatMessage::NoteMessage.new(data)
when "pipeline" when "pipeline"
...@@ -136,7 +136,7 @@ class ChatNotificationService < Service ...@@ -136,7 +136,7 @@ class ChatNotificationService < Service
project.web_url project.web_url
end end
def is_update?(data) def update?(data)
data[:object_attributes][:action] == 'update' data[:object_attributes][:action] == 'update'
end end
......
...@@ -85,9 +85,9 @@ class HipchatService < Service ...@@ -85,9 +85,9 @@ class HipchatService < Service
when "push", "tag_push" when "push", "tag_push"
create_push_message(data) create_push_message(data)
when "issue" when "issue"
create_issue_message(data) unless is_update?(data) create_issue_message(data) unless update?(data)
when "merge_request" when "merge_request"
create_merge_request_message(data) unless is_update?(data) create_merge_request_message(data) unless update?(data)
when "note" when "note"
create_note_message(data) create_note_message(data)
when "pipeline" when "pipeline"
...@@ -282,7 +282,7 @@ class HipchatService < Service ...@@ -282,7 +282,7 @@ class HipchatService < Service
"<a href=\"#{project_url}\">#{project_name}</a>" "<a href=\"#{project_url}\">#{project_name}</a>"
end end
def is_update?(data) def update?(data)
data[:object_attributes][:action] == 'update' data[:object_attributes][:action] == 'update'
end end
......
...@@ -60,6 +60,10 @@ class Repository ...@@ -60,6 +60,10 @@ class Repository
@project = project @project = project
end end
def ==(other)
@disk_path == other.disk_path
end
def raw_repository def raw_repository
return nil unless full_path return nil unless full_path
...@@ -75,6 +79,10 @@ class Repository ...@@ -75,6 +79,10 @@ class Repository
) )
end end
def inspect
"#<#{self.class.name}:#{@disk_path}>"
end
# #
# Git repository can contains some hidden refs like: # Git repository can contains some hidden refs like:
# /refs/notes/* # /refs/notes/*
...@@ -944,7 +952,7 @@ class Repository ...@@ -944,7 +952,7 @@ class Repository
if branch_commit if branch_commit
same_head = branch_commit.id == root_ref_commit.id same_head = branch_commit.id == root_ref_commit.id
!same_head && is_ancestor?(branch_commit.id, root_ref_commit.id) !same_head && ancestor?(branch_commit.id, root_ref_commit.id)
else else
nil nil
end end
...@@ -958,12 +966,12 @@ class Repository ...@@ -958,12 +966,12 @@ class Repository
nil nil
end end
def is_ancestor?(ancestor_id, descendant_id) def ancestor?(ancestor_id, descendant_id)
return false if ancestor_id.nil? || descendant_id.nil? return false if ancestor_id.nil? || descendant_id.nil?
Gitlab::GitalyClient.migrate(:is_ancestor) do |is_enabled| Gitlab::GitalyClient.migrate(:is_ancestor) do |is_enabled|
if is_enabled if is_enabled
raw_repository.is_ancestor?(ancestor_id, descendant_id) raw_repository.ancestor?(ancestor_id, descendant_id)
else else
rugged_is_ancestor?(ancestor_id, descendant_id) rugged_is_ancestor?(ancestor_id, descendant_id)
end end
...@@ -992,25 +1000,22 @@ class Repository ...@@ -992,25 +1000,22 @@ class Repository
end end
def with_repo_branch_commit(start_repository, start_branch_name) def with_repo_branch_commit(start_repository, start_branch_name)
return yield(nil) if start_repository.empty_repo? return yield nil if start_repository.empty_repo?
branch_name_or_sha =
if start_repository == self if start_repository == self
start_branch_name yield commit(start_branch_name)
else else
tmp_ref = fetch_ref( sha = start_repository.commit(start_branch_name).sha
start_repository.path_to_repo,
"#{Gitlab::Git::BRANCH_REF_PREFIX}#{start_branch_name}",
"refs/tmp/#{SecureRandom.hex}/head"
)
start_repository.commit(start_branch_name).sha if branch_commit = commit(sha)
yield branch_commit
else
with_repo_tmp_commit(
start_repository, start_branch_name, sha) do |tmp_commit|
yield tmp_commit
end
end
end end
yield(commit(branch_name_or_sha))
ensure
rugged.references.delete(tmp_ref) if tmp_ref
end end
def add_remote(name, url) def add_remote(name, url)
...@@ -1219,4 +1224,16 @@ class Repository ...@@ -1219,4 +1224,16 @@ class Repository
.commits_by_message(query, revision: ref, path: path, limit: limit, offset: offset) .commits_by_message(query, revision: ref, path: path, limit: limit, offset: offset)
.map { |c| commit(c) } .map { |c| commit(c) }
end end
def with_repo_tmp_commit(start_repository, start_branch_name, sha)
tmp_ref = fetch_ref(
start_repository.path_to_repo,
"#{Gitlab::Git::BRANCH_REF_PREFIX}#{start_branch_name}",
"refs/tmp/#{SecureRandom.hex}/head"
)
yield commit(sha)
ensure
rugged.references.delete(tmp_ref) if tmp_ref
end
end end
...@@ -5,6 +5,7 @@ class User < ActiveRecord::Base ...@@ -5,6 +5,7 @@ class User < ActiveRecord::Base
include Gitlab::ConfigHelper include Gitlab::ConfigHelper
include Gitlab::CurrentSettings include Gitlab::CurrentSettings
include Gitlab::SQL::Pattern
include Avatarable include Avatarable
include Referable include Referable
include Sortable include Sortable
...@@ -303,7 +304,7 @@ class User < ActiveRecord::Base ...@@ -303,7 +304,7 @@ class User < ActiveRecord::Base
# Returns an ActiveRecord::Relation. # Returns an ActiveRecord::Relation.
def search(query) def search(query)
table = arel_table table = arel_table
pattern = "%#{query}%" pattern = User.to_pattern(query)
order = <<~SQL order = <<~SQL
CASE CASE
......
...@@ -17,13 +17,13 @@ class ProjectPolicy < BasePolicy ...@@ -17,13 +17,13 @@ class ProjectPolicy < BasePolicy
desc "Project has public builds enabled" desc "Project has public builds enabled"
condition(:public_builds, scope: :subject) { project.public_builds? } condition(:public_builds, scope: :subject) { project.public_builds? }
# For guest access we use #is_team_member? so we can use # For guest access we use #team_member? so we can use
# project.members, which gets cached in subject scope. # project.members, which gets cached in subject scope.
# This is safe because team_access_level is guaranteed # This is safe because team_access_level is guaranteed
# by ProjectAuthorization's validation to be at minimum # by ProjectAuthorization's validation to be at minimum
# GUEST # GUEST
desc "User has guest access" desc "User has guest access"
condition(:guest) { is_team_member? } condition(:guest) { team_member? }
desc "User has reporter access" desc "User has reporter access"
condition(:reporter) { team_access_level >= Gitlab::Access::REPORTER } condition(:reporter) { team_access_level >= Gitlab::Access::REPORTER }
...@@ -293,7 +293,7 @@ class ProjectPolicy < BasePolicy ...@@ -293,7 +293,7 @@ class ProjectPolicy < BasePolicy
private private
def is_team_member? def team_member?
return false if @user.nil? return false if @user.nil?
greedy_load_subject = false greedy_load_subject = false
......
...@@ -7,7 +7,7 @@ class AkismetService ...@@ -7,7 +7,7 @@ class AkismetService
@options = options @options = options
end end
def is_spam? def spam?
return false unless akismet_enabled? return false unless akismet_enabled?
params = { params = {
......
...@@ -30,7 +30,7 @@ class GitPushService < BaseService ...@@ -30,7 +30,7 @@ class GitPushService < BaseService
@project.repository.after_create_branch @project.repository.after_create_branch
# Re-find the pushed commits. # Re-find the pushed commits.
if is_default_branch? if default_branch?
# Initial push to the default branch. Take the full history of that branch as "newly pushed". # Initial push to the default branch. Take the full history of that branch as "newly pushed".
process_default_branch process_default_branch
else else
...@@ -50,7 +50,7 @@ class GitPushService < BaseService ...@@ -50,7 +50,7 @@ class GitPushService < BaseService
# Update the bare repositories info/attributes file using the contents of the default branches # Update the bare repositories info/attributes file using the contents of the default branches
# .gitattributes file # .gitattributes file
update_gitattributes if is_default_branch? update_gitattributes if default_branch?
end end
execute_related_hooks execute_related_hooks
...@@ -66,7 +66,7 @@ class GitPushService < BaseService ...@@ -66,7 +66,7 @@ class GitPushService < BaseService
end end
def update_caches def update_caches
if is_default_branch? if default_branch?
if push_to_new_branch? if push_to_new_branch?
# If this is the initial push into the default branch, the file type caches # If this is the initial push into the default branch, the file type caches
# will already be reset as a result of `Project#change_head`. # will already be reset as a result of `Project#change_head`.
...@@ -108,7 +108,7 @@ class GitPushService < BaseService ...@@ -108,7 +108,7 @@ class GitPushService < BaseService
# Schedules processing of commit messages. # Schedules processing of commit messages.
def process_commit_messages def process_commit_messages
default = is_default_branch? default = default_branch?
@push_commits.last(PROCESS_COMMIT_LIMIT).each do |commit| @push_commits.last(PROCESS_COMMIT_LIMIT).each do |commit|
if commit.matches_cross_reference_regex? if commit.matches_cross_reference_regex?
...@@ -202,7 +202,7 @@ class GitPushService < BaseService ...@@ -202,7 +202,7 @@ class GitPushService < BaseService
Gitlab::Git.branch_ref?(params[:ref]) Gitlab::Git.branch_ref?(params[:ref])
end end
def is_default_branch? def default_branch?
Gitlab::Git.branch_ref?(params[:ref]) && Gitlab::Git.branch_ref?(params[:ref]) &&
(Gitlab::Git.ref_name(params[:ref]) == project.default_branch || project.default_branch.nil?) (Gitlab::Git.ref_name(params[:ref]) == project.default_branch || project.default_branch.nil?)
end end
......
module Milestones module Milestones
class CloseService < Milestones::BaseService class CloseService < Milestones::BaseService
def execute(milestone) def execute(milestone)
if milestone.close && milestone.is_project_milestone? if milestone.close && milestone.project_milestone?
event_service.close_milestone(milestone, current_user) event_service.close_milestone(milestone, current_user)
end end
......
...@@ -3,7 +3,7 @@ module Milestones ...@@ -3,7 +3,7 @@ module Milestones
def execute def execute
milestone = parent.milestones.new(params) milestone = parent.milestones.new(params)
if milestone.save && milestone.is_project_milestone? if milestone.save && milestone.project_milestone?
event_service.open_milestone(milestone, current_user) event_service.open_milestone(milestone, current_user)
end end
......
module Milestones module Milestones
class DestroyService < Milestones::BaseService class DestroyService < Milestones::BaseService
def execute(milestone) def execute(milestone)
return unless milestone.is_project_milestone? return unless milestone.project_milestone?
Milestone.transaction do Milestone.transaction do
update_params = { milestone: nil } update_params = { milestone: nil }
......
module Milestones module Milestones
class ReopenService < Milestones::BaseService class ReopenService < Milestones::BaseService
def execute(milestone) def execute(milestone)
if milestone.activate && milestone.is_project_milestone? if milestone.activate && milestone.project_milestone?
event_service.reopen_milestone(milestone, current_user) event_service.reopen_milestone(milestone, current_user)
end end
......
...@@ -44,6 +44,8 @@ module Projects ...@@ -44,6 +44,8 @@ module Projects
@project.namespace_id = current_user.namespace_id @project.namespace_id = current_user.namespace_id
end end
yield(@project) if block_given?
@project.creator = current_user @project.creator = current_user
if forked_from_project_id if forked_from_project_id
......
...@@ -45,7 +45,7 @@ class SpamService ...@@ -45,7 +45,7 @@ class SpamService
def check(api) def check(api)
return false unless request && check_for_spam? return false unless request && check_for_spam?
return false unless akismet.is_spam? return false unless akismet.spam?
create_spam_log(api) create_spam_log(api)
true true
......
...@@ -142,7 +142,7 @@ module SystemNoteService ...@@ -142,7 +142,7 @@ module SystemNoteService
# #
# Returns the created Note object # Returns the created Note object
def change_milestone(noteable, project, author, milestone) def change_milestone(noteable, project, author, milestone)
format = milestone&.is_group_milestone? ? :name : :iid format = milestone&.group_milestone? ? :name : :iid
body = milestone.nil? ? 'removed milestone' : "changed milestone to #{milestone.to_reference(project, format: format)}" body = milestone.nil? ? 'removed milestone' : "changed milestone to #{milestone.to_reference(project, format: format)}"
create_note(NoteSummary.new(noteable, project, author, body, action: 'milestone')) create_note(NoteSummary.new(noteable, project, author, body, action: 'milestone'))
......
= render "header_title" = render "header_title"
= render 'shared/milestones/top', milestone: @milestone, group: @group = render 'shared/milestones/top', milestone: @milestone, group: @group
= render 'shared/milestones/tabs', milestone: @milestone, show_project_name: true if @milestone.is_legacy_group_milestone? = render 'shared/milestones/tabs', milestone: @milestone, show_project_name: true if @milestone.legacy_group_milestone?
= render 'shared/milestones/sidebar', milestone: @milestone, affix_offset: 102 = render 'shared/milestones/sidebar', milestone: @milestone, affix_offset: 102
- breadcrumb_link = breadcrumb_title_link - breadcrumb_link = breadcrumb_title_link
- container = @no_breadcrumb_container ? 'container-fluid' : container_class
- hide_top_links = @hide_top_links || false - hide_top_links = @hide_top_links || false
%nav.breadcrumbs{ role: "navigation" } %nav.breadcrumbs{ role: "navigation" }
.breadcrumbs-container{ class: [container_class, @content_class] } .breadcrumbs-container{ class: [container, @content_class] }
- if defined?(@new_sidebar) - if defined?(@new_sidebar)
= button_tag class: 'toggle-mobile-nav', type: 'button' do = button_tag class: 'toggle-mobile-nav', type: 'button' do
%span.sr-only Open sidebar %span.sr-only Open sidebar
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
Add a GPG key Add a GPG key
%p.profile-settings-content %p.profile-settings-content
Before you can add a GPG key you need to Before you can add a GPG key you need to
= link_to 'generate it.', help_page_path('user/project/gpg_signed_commits/index.md') = link_to 'generate it.', help_page_path('user/project/repository/gpg_signed_commits/index.md')
= render 'form' = render 'form'
%hr %hr
%h5 %h5
......
- @no_breadcrumb_container = true
- @no_container = true - @no_container = true
- @content_class = "issue-boards-content" - @content_class = "issue-boards-content"
- page_title "Boards" - page_title "Boards"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
%span.monospace= signature.gpg_key_primary_keyid %span.monospace= signature.gpg_key_primary_keyid
= link_to('Learn more about signing commits', help_page_path('user/project/gpg_signed_commits/index.md'), class: 'gpg-popover-help-link') = link_to('Learn more about signing commits', help_page_path('user/project/repository/gpg_signed_commits/index.md'), class: 'gpg-popover-help-link')
%button{ class: css_classes, data: { toggle: 'popover', html: 'true', placement: 'auto top', title: title, content: content } } %button{ class: css_classes, data: { toggle: 'popover', html: 'true', placement: 'auto top', title: title, content: content } }
= label = label
...@@ -93,6 +93,13 @@ ...@@ -93,6 +93,13 @@
%span.dropdown-label-box{ style: 'background: {{color}}' } %span.dropdown-label-box{ style: 'background: {{color}}' }
%span.label-title.js-data-value %span.label-title.js-data-value
{{title}} {{title}}
#js-dropdown-my-reaction.filtered-search-input-dropdown-menu.dropdown-menu
%ul.filter-dropdown{ data: { dynamic: true, dropdown: true } }
%li.filter-dropdown-item
%button.btn.btn-link
%gl-emoji
%span.js-data-value.prepend-left-10
{{name}}
%button.clear-search.hidden{ type: 'button' } %button.clear-search.hidden{ type: 'button' }
= icon('times') = icon('times')
.filter-dropdown-container .filter-dropdown-container
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
.row .row
.col-sm-6 .col-sm-6
%strong= link_to truncate(milestone.title, length: 100), milestone_path %strong= link_to truncate(milestone.title, length: 100), milestone_path
- if milestone.is_group_milestone? - if milestone.group_milestone?
%span - Group Milestone %span - Group Milestone
- else - else
%span - Project Milestone %span - Project Milestone
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
&middot; &middot;
= link_to pluralize(milestone.merge_requests.size, 'Merge Request'), merge_requests_path = link_to pluralize(milestone.merge_requests.size, 'Merge Request'), merge_requests_path
.col-sm-6= milestone_progress_bar(milestone) .col-sm-6= milestone_progress_bar(milestone)
- if milestone.is_a?(GlobalMilestone) || milestone.is_group_milestone? - if milestone.is_a?(GlobalMilestone) || milestone.group_milestone?
.row .row
.col-sm-6 .col-sm-6
- if milestone.is_legacy_group_milestone? - if milestone.legacy_group_milestone?
.expiration= render('shared/milestone_expired', milestone: milestone) .expiration= render('shared/milestone_expired', milestone: milestone)
.projects .projects
- milestone.milestones.each do |milestone| - milestone.milestones.each do |milestone|
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
- if @group - if @group
.col-sm-6.milestone-actions .col-sm-6.milestone-actions
- if can?(current_user, :admin_milestones, @group) - if can?(current_user, :admin_milestones, @group)
- if milestone.is_group_milestone? - if milestone.group_milestone?
= link_to edit_group_milestone_path(@group, milestone), class: "btn btn-xs btn-grouped" do = link_to edit_group_milestone_path(@group, milestone), class: "btn btn-xs btn-grouped" do
Edit Edit
\ \
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
- if group - if group
.pull-right .pull-right
- if can?(current_user, :admin_milestones, group) - if can?(current_user, :admin_milestones, group)
- if milestone.is_group_milestone? - if milestone.group_milestone?
= link_to edit_group_milestone_path(group, milestone), class: "btn btn btn-grouped" do = link_to edit_group_milestone_path(group, milestone), class: "btn btn btn-grouped" do
Edit Edit
- if milestone.active? - if milestone.active?
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
.detail-page-description.milestone-detail .detail-page-description.milestone-detail
%h2.title %h2.title
= markdown_field(milestone, :title) = markdown_field(milestone, :title)
- if @milestone.is_group_milestone? && @milestone.description.present? - if @milestone.group_milestone? && @milestone.description.present?
%div %div
.description .description
.wiki .wiki
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
- close_msg = group ? 'You may close the milestone now.' : 'Navigate to the project to close the milestone.' - close_msg = group ? 'You may close the milestone now.' : 'Navigate to the project to close the milestone.'
%span All issues for this milestone are closed. #{close_msg} %span All issues for this milestone are closed. #{close_msg}
- if @milestone.is_legacy_group_milestone? || @milestone.is_dashboard_milestone? - if @milestone.legacy_group_milestone? || @milestone.dashboard_milestone?
.table-holder .table-holder
%table.table %table.table
%thead %thead
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
Open Open
%td %td
= ms.expires_at = ms.expires_at
- elsif @milestone.is_group_milestone? - elsif @milestone.group_milestone?
%br %br
View View
= link_to 'Issues', issues_group_path(@group, milestone_title: milestone.title) = link_to 'Issues', issues_group_path(@group, milestone_title: milestone.title)
......
---
title: Fixes margins on the top buttons of the pipeline table
merge_request:
author:
type: fixed
---
title: Prevents rendering empty badges when request fails
merge_request:
author:
type: fixed
---
title: Remove `is_` prefix from predicate method names
merge_request: 13810
author: Maxim Rydkin
type: other
---
title: Better align fallback image emojis
merge_request:
author:
type: fixed
---
title: 'API: Respect default group visibility when creating a group'
merge_request: 13903
author: Robert Schilling
type: fixed
---
title: Add my reaction filter to search bar
merge_request: 12962
author: Hiroyuki Sato
---
title: 'API: Respect the "If-Unmodified-Since" header when delting a resource'
merge_request: 9621
author: Robert Schilling
type: added
---
title: Fixed diff changes bar buttons from showing/hiding whilst scrolling
merge_request:
author:
type: fixed
---
title: Improve performance for AutocompleteController#users.json
merge_request: 13754
author: Hiroyuki Sato
type: changed
---
title: Fix breadcrumbs container in issue boards
merge_request:
author:
type: fixed
---
title: Eager load head pipeline projects for MRs index
merge_request:
author:
type: other
---
title: Fix repository equality check and avoid fetching ref if the commit is already
available. This affects merge request creation performance
merge_request: 13685
author:
type: other
---
title: Replace 'project/star.feature' spinach test with an rspec analog
merge_request: 13855
author: Vitaliy @blackst0ne Klachkov
type: other
---
title: Replace 'project/user_lookup.feature' spinach test with an rspec analog
merge_request: 13863
author: Vitaliy @blackst0ne Klachkov
type: other
require 'prometheus/client' require 'prometheus/client'
require 'prometheus/client/support/unicorn'
Prometheus::Client.configure do |config| Prometheus::Client.configure do |config|
config.logger = Rails.logger config.logger = Rails.logger
...@@ -9,6 +10,8 @@ Prometheus::Client.configure do |config| ...@@ -9,6 +10,8 @@ Prometheus::Client.configure do |config|
if Rails.env.development? || Rails.env.test? if Rails.env.development? || Rails.env.test?
config.multiprocess_files_dir ||= Rails.root.join('tmp/prometheus_multiproc_dir') config.multiprocess_files_dir ||= Rails.root.join('tmp/prometheus_multiproc_dir')
end end
config.pid_provider = Prometheus::Client::Support::Unicorn.method(:worker_pid_provider)
end end
Sidekiq.configure_server do |config| Sidekiq.configure_server do |config|
......
...@@ -27,6 +27,7 @@ Rails.application.routes.draw do ...@@ -27,6 +27,7 @@ Rails.application.routes.draw do
get '/autocomplete/users' => 'autocomplete#users' get '/autocomplete/users' => 'autocomplete#users'
get '/autocomplete/users/:id' => 'autocomplete#user' get '/autocomplete/users/:id' => 'autocomplete#user'
get '/autocomplete/projects' => 'autocomplete#projects' get '/autocomplete/projects' => 'autocomplete#projects'
get '/autocomplete/award_emojis' => 'autocomplete#award_emojis'
# Search # Search
get 'search' => 'search#show' get 'search' => 'search#show'
......
...@@ -77,6 +77,8 @@ Manage your [repositories](user/project/repository/index.md) from the UI (user i ...@@ -77,6 +77,8 @@ Manage your [repositories](user/project/repository/index.md) from the UI (user i
- [Create a branch](user/project/repository/web_editor.md#create-a-new-branch) - [Create a branch](user/project/repository/web_editor.md#create-a-new-branch)
- [Protected branches](user/project/protected_branches.md#protected-branches) - [Protected branches](user/project/protected_branches.md#protected-branches)
- [Delete merged branches](user/project/repository/branches/index.md#delete-merged-branches) - [Delete merged branches](user/project/repository/branches/index.md#delete-merged-branches)
- Commits
- [Signing commits](user/project/repository/gpg_signed_commits/index.md): use GPG to sign your commits.
### Issues and Merge Requests (MRs) ### Issues and Merge Requests (MRs)
...@@ -98,7 +100,6 @@ Manage your [repositories](user/project/repository/index.md) from the UI (user i ...@@ -98,7 +100,6 @@ Manage your [repositories](user/project/repository/index.md) from the UI (user i
- [Git](topics/git/index.md): Getting started with Git, branching strategies, Git LFS, advanced use. - [Git](topics/git/index.md): Getting started with Git, branching strategies, Git LFS, advanced use.
- [Git cheatsheet](https://gitlab.com/gitlab-com/marketing/raw/master/design/print/git-cheatsheet/print-pdf/git-cheatsheet.pdf): Download a PDF describing the most used Git operations. - [Git cheatsheet](https://gitlab.com/gitlab-com/marketing/raw/master/design/print/git-cheatsheet/print-pdf/git-cheatsheet.pdf): Download a PDF describing the most used Git operations.
- [GitLab Flow](workflow/gitlab_flow.md): explore the best of Git with the GitLab Flow strategy. - [GitLab Flow](workflow/gitlab_flow.md): explore the best of Git with the GitLab Flow strategy.
- [Signing commits](user/project/gpg_signed_commits/index.md): use GPG to sign your commits.
### Migrate and import your projects from other platforms ### Migrate and import your projects from other platforms
......
...@@ -263,6 +263,7 @@ The following table shows the possible return codes for API requests. ...@@ -263,6 +263,7 @@ The following table shows the possible return codes for API requests.
| `404 Not Found` | A resource could not be accessed, e.g., an ID for a resource could not be found. | | `404 Not Found` | A resource could not be accessed, e.g., an ID for a resource could not be found. |
| `405 Method Not Allowed` | The request is not supported. | | `405 Method Not Allowed` | The request is not supported. |
| `409 Conflict` | A conflicting resource already exists, e.g., creating a project with a name that already exists. | | `409 Conflict` | A conflicting resource already exists, e.g., creating a project with a name that already exists. |
| `412` | Indicates the request was denied. May happen if the `If-Unmodified-Since` header is provided when trying to delete a resource, which was modified in between. |
| `422 Unprocessable` | The entity could not be processed. | | `422 Unprocessable` | The entity could not be processed. |
| `500 Server Error` | While handling the request something went wrong server-side. | | `500 Server Error` | While handling the request something went wrong server-side. |
......
...@@ -102,42 +102,41 @@ followed by any global declarations, then a blank newline prior to any imports o ...@@ -102,42 +102,41 @@ followed by any global declarations, then a blank newline prior to any imports o
1. Relative paths: when importing a module in the same directory, a child 1. Relative paths: when importing a module in the same directory, a child
directory, or an immediate parent directory prefer relative paths. When directory, or an immediate parent directory prefer relative paths. When
importing a module which is two or more levels up, prefer either `~/` or `ee/` importing a module which is two or more levels up, prefer either `~/` or `ee/`.
.
In **app/assets/javascripts/my-feature/subdir**: In **app/assets/javascripts/my-feature/subdir**:
``` javascript ```javascript
// bad // bad
import Foo from '~/my-feature/foo'; import Foo from '~/my-feature/foo';
import Bar from '~/my-feature/subdir/bar'; import Bar from '~/my-feature/subdir/bar';
import Bin from '~/my-feature/subdir/lib/bin'; import Bin from '~/my-feature/subdir/lib/bin';
// good // good
import Foo from '../foo'; import Foo from '../foo';
import Bar from './bar'; import Bar from './bar';
import Bin from './lib/bin'; import Bin from './lib/bin';
``` ```
In **spec/javascripts**: In **spec/javascripts**:
``` javascript ```javascript
// bad // bad
import Foo from '../../app/assets/javascripts/my-feature/foo'; import Foo from '../../app/assets/javascripts/my-feature/foo';
// good // good
import Foo from '~/my-feature/foo'; import Foo from '~/my-feature/foo';
``` ```
When referencing an **EE component**: When referencing an **EE component**:
``` javascript ```javascript
// bad // bad
import Foo from '../../../../../ee/app/assets/javascripts/my-feature/ee-foo'; import Foo from '../../../../../ee/app/assets/javascripts/my-feature/ee-foo';
// good // good
import Foo from 'ee/my-feature/foo'; import Foo from 'ee/my-feature/foo';
``` ```
1. Avoid using IIFE. Although we have a lot of examples of files which wrap their 1. Avoid using IIFE. Although we have a lot of examples of files which wrap their
contents in IIFEs (immediately-invoked function expressions), contents in IIFEs (immediately-invoked function expressions),
...@@ -163,7 +162,6 @@ Do not use them anymore and feel free to remove them when refactoring legacy cod ...@@ -163,7 +162,6 @@ Do not use them anymore and feel free to remove them when refactoring legacy cod
} }
``` ```
#### Data Mutation and Pure functions #### Data Mutation and Pure functions
1. Strive to write many small pure functions, and minimize where mutations occur. 1. Strive to write many small pure functions, and minimize where mutations occur.
```javascript ```javascript
...@@ -481,7 +479,8 @@ A forEach will cause side effects, it will be mutating the array being iterated. ...@@ -481,7 +479,8 @@ A forEach will cause side effects, it will be mutating the array being iterated.
1. `beforeDestroy` 1. `beforeDestroy`
1. `destroyed` 1. `destroyed`
#### Vue and Boostrap #### Vue and Bootstrap
1. Tooltips: Do not rely on `has-tooltip` class name for Vue components 1. Tooltips: Do not rely on `has-tooltip` class name for Vue components
```javascript ```javascript
// bad // bad
...@@ -511,23 +510,19 @@ A forEach will cause side effects, it will be mutating the array being iterated. ...@@ -511,23 +510,19 @@ A forEach will cause side effects, it will be mutating the array being iterated.
$('span').tooltip('fixTitle'); $('span').tooltip('fixTitle');
``` ```
### The Javascript/Vue Accord ### The Javascript/Vue Accord
The goal of this accord is to make sure we are all on the same page. The goal of this accord is to make sure we are all on the same page.
1. When writing Vue, you may not use jQuery in your application. 1. When writing Vue, you may not use jQuery in your application.
1.1 If you need to grab data from the DOM, you may query the DOM 1 time while bootstrapping your application to grab data attributes using `dataset`. You can do this without jQuery. 1. If you need to grab data from the DOM, you may query the DOM 1 time while bootstrapping your application to grab data attributes using `dataset`. You can do this without jQuery.
1.2 You may use a jQuery dependency in Vue.js following [this example from the docs](https://vuejs.org/v2/examples/select2.html). 1. You may use a jQuery dependency in Vue.js following [this example from the docs](https://vuejs.org/v2/examples/select2.html).
1.3 If an outside jQuery Event needs to be listen to inside the Vue application, you may use jQuery event listeners. 1. If an outside jQuery Event needs to be listen to inside the Vue application, you may use jQuery event listeners.
1.4 We will avoid adding new jQuery events when they are not required. Instead of adding new jQuery events take a look at [different methods to do the same task](https://vuejs.org/v2/api/#vm-emit). 1. We will avoid adding new jQuery events when they are not required. Instead of adding new jQuery events take a look at [different methods to do the same task](https://vuejs.org/v2/api/#vm-emit).
1. You may query the `window` object 1 time, while bootstrapping your application for application specific data (e.g. `scrollTo` is ok to access anytime). Do this access during the bootstrapping of your application. 1. You may query the `window` object 1 time, while bootstrapping your application for application specific data (e.g. `scrollTo` is ok to access anytime). Do this access during the bootstrapping of your application.
1. You may have a temporary but immediate need to create technical debt by writing code that does not follow our standards, to be refactored later. Maintainers need to be ok with the tech debt in the first place. An issue should be created for that tech debt to evaluate it further and discuss. In the coming months you should fix that tech debt, with it's priority to be determined by maintainers. 1. You may have a temporary but immediate need to create technical debt by writing code that does not follow our standards, to be refactored later. Maintainers need to be ok with the tech debt in the first place. An issue should be created for that tech debt to evaluate it further and discuss. In the coming months you should fix that tech debt, with it's priority to be determined by maintainers.
1. When creating tech debt you must write the tests for that code before hand and those tests may not be rewritten. e.g. jQuery tests rewritten to Vue tests. 1. When creating tech debt you must write the tests for that code before hand and those tests may not be rewritten. e.g. jQuery tests rewritten to Vue tests.
1. You may choose to use VueX as a centralized state management. If you choose not to use VueX, you must use the *store pattern* which can be found in the [Vue.js documentation](https://vuejs.org/v2/guide/state-management.html#Simple-State-Management-from-Scratch). 1. You may choose to use VueX as a centralized state management. If you choose not to use VueX, you must use the *store pattern* which can be found in the [Vue.js documentation](https://vuejs.org/v2/guide/state-management.html#Simple-State-Management-from-Scratch).
1. Once you have chosen a centralized state management solution you must use it for your entire application. i.e. Don't mix and match your state management solutions. 1. Once you have chosen a centralized state management solution you must use it for your entire application. i.e. Don't mix and match your state management solutions.
## SCSS ## SCSS
......
...@@ -144,9 +144,8 @@ gitlab_rails['backup_upload_connection'] = { ...@@ -144,9 +144,8 @@ gitlab_rails['backup_upload_connection'] = {
'region' => 'eu-west-1', 'region' => 'eu-west-1',
'aws_access_key_id' => 'AKIAKIAKI', 'aws_access_key_id' => 'AKIAKIAKI',
'aws_secret_access_key' => 'secret123' 'aws_secret_access_key' => 'secret123'
# If using an IAM Profile, leave aws_access_key_id & aws_secret_access_key empty # If using an IAM Profile, don't configure aws_access_key_id & aws_secret_access_key
# ie. 'aws_access_key_id' => '', # 'use_iam_profile' => true
# 'use_iam_profile' => 'true'
} }
gitlab_rails['backup_upload_remote_directory'] = 'my.s3.bucket' gitlab_rails['backup_upload_remote_directory'] = 'my.s3.bucket'
``` ```
......
# Signing commits with GPG This document was moved to [another location](../repository/gpg_signed_commits/index.md).
> [Introduced][ce-9546] in GitLab 9.5.
GitLab can show whether a commit is verified or not when signed with a GPG key.
All you need to do is upload the public GPG key in your profile settings.
GPG verified tags are not supported yet.
## Getting started with GPG
Here are a few guides to get you started with GPG:
- [Git Tools - Signing Your Work](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work)
- [Managing OpenPGP Keys](https://riseup.net/en/security/message-security/openpgp/gpg-keys)
- [OpenPGP Best Practices](https://riseup.net/en/security/message-security/openpgp/best-practices)
- [Creating a new GPG key with subkeys](https://www.void.gr/kargig/blog/2013/12/02/creating-a-new-gpg-key-with-subkeys/) (advanced)
## How GitLab handles GPG
GitLab uses its own keyring to verify the GPG signature. It does not access any
public key server.
In order to have a commit verified on GitLab the corresponding public key needs
to be uploaded to GitLab. For a signature to be verified two prerequisites need
to be met:
1. The public key needs to be added your GitLab account
1. One of the emails in the GPG key matches your **primary** email
## Generating a GPG key
If you don't already have a GPG key, the following steps will help you get
started:
1. [Install GPG](https://www.gnupg.org/download/index.html) for your operating system
1. Generate the private/public key pair with the following command:
```sh
gpg --full-gen-key
```
This will spawn a series of questions.
1. The first question is which algorithm can be used. Select the kind you want
or press <kbd>Enter</kbd> to choose the default (RSA and RSA):
```
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection? 1
```
1. The next question is key length. We recommend to choose the highest value
which is `4096`:
```
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 4096
Requested keysize is 4096 bits
```
1. Next, you need to specify the validity period of your key. This is something
subjective, and you can use the default value which is to never expire:
```
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0) 0
Key does not expire at all
```
1. Confirm that the answers you gave were correct by typing `y`:
```
Is this correct? (y/N) y
```
1. Enter you real name, the email address to be associated with this key (should
match the primary email address you use in GitLab) and an optional comment
(press <kbd>Enter</kbd> to skip):
```
GnuPG needs to construct a user ID to identify your key.
Real name: Mr. Robot
Email address: mr@robot.sh
Comment:
You selected this USER-ID:
"Mr. Robot <mr@robot.sh>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
```
1. Pick a strong password when asked and type it twice to confirm.
1. Use the following command to list the private GPG key you just created:
```
gpg --list-secret-keys mr@robot.sh
```
Replace `mr@robot.sh` with the email address you entered above.
1. Copy the GPG key ID that starts with `sec`. In the following example, that's
`0x30F2B65B9246B6CA`:
```
sec rsa4096/0x30F2B65B9246B6CA 2017-08-18 [SC]
D5E4F29F3275DC0CDA8FFC8730F2B65B9246B6CA
uid [ultimate] Mr. Robot <mr@robot.sh>
ssb rsa4096/0xB7ABC0813E4028C0 2017-08-18 [E]
```
1. Export the public key of that ID (replace your key ID from the previous step):
```
gpg --armor --export 0x30F2B65B9246B6CA
```
1. Finally, copy the public key and [add it in your profile settings](#adding-a-gpg-key-to-your-account)
## Adding a GPG key to your account
>**Note:**
Once you add a key, you cannot edit it, only remove it. In case the paste
didn't work, you'll have to remove the offending key and re-add it.
You can add a GPG key in your profile's settings:
1. On the upper right corner, click on your avatar and go to your **Settings**.
![Settings dropdown](../../profile/img/profile_settings_dropdown.png)
1. Navigate to the **GPG keys** tab and paste your _public_ key in the 'Key'
box.
![Paste GPG public key](img/profile_settings_gpg_keys_paste_pub.png)
1. Finally, click on **Add key** to add it to GitLab. You will be able to see
its fingerprint, the corresponding email address and creation date.
![GPG key single page](img/profile_settings_gpg_keys_single_key.png)
## Associating your GPG key with Git
After you have [created your GPG key](#generating-a-gpg-key) and [added it to
your account](#adding-a-gpg-key-to-your-account), it's time to tell Git which
key to use.
1. Use the following command to list the private GPG key you just created:
```
gpg --list-secret-keys mr@robot.sh
```
Replace `mr@robot.sh` with the email address you entered above.
1. Copy the GPG key ID that starts with `sec`. In the following example, that's
`0x30F2B65B9246B6CA`:
```
sec rsa4096/0x30F2B65B9246B6CA 2017-08-18 [SC]
D5E4F29F3275DC0CDA8FFC8730F2B65B9246B6CA
uid [ultimate] Mr. Robot <mr@robot.sh>
ssb rsa4096/0xB7ABC0813E4028C0 2017-08-18 [E]
```
1. Tell Git to use that key to sign the commits:
```
git config --global user.signingkey 0x30F2B65B9246B6CA
```
Replace `0x30F2B65B9246B6CA` with your GPG key ID.
## Signing commits
After you have [created your GPG key](#generating-a-gpg-key) and [added it to
your account](#adding-a-gpg-key-to-your-account), you can start signing your
commits:
1. Commit like you used to, the only difference is the addition of the `-S` flag:
```
git commit -S -m "My commit msg"
```
1. Enter the passphrase of your GPG key when asked.
1. Push to GitLab and check that your commits [are verified](#verifying-commits).
If you don't want to type the `-S` flag every time you commit, you can tell Git
to sign your commits automatically:
```
git config --global commit.gpgsign true
```
## Verifying commits
1. Within a project or [merge request](../merge_requests/index.md), navigate to
the **Commits** tab. Signed commits will show a badge containing either
"Verified" or "Unverified", depending on the verification status of the GPG
signature.
![Signed and unsigned commits](img/project_signed_and_unsigned_commits.png)
1. By clicking on the GPG badge, details of the signature are displayed.
![Signed commit with verified signature](img/project_signed_commit_verified_signature.png)
![Signed commit with verified signature](img/project_signed_commit_unverified_signature.png)
## Revoking a GPG key
Revoking a key **unverifies** already signed commits. Commits that were
verified by using this key will change to an unverified state. Future commits
will also stay unverified once you revoke this key. This action should be used
in case your key has been compromised.
To revoke a GPG key:
1. On the upper right corner, click on your avatar and go to your **Settings**.
1. Navigate to the **GPG keys** tab.
1. Click on **Revoke** besides the GPG key you want to delete.
## Removing a GPG key
Removing a key **does not unverify** already signed commits. Commits that were
verified by using this key will stay verified. Only unpushed commits will stay
unverified once you remove this key. To unverify already signed commits, you need
to [revoke the associated GPG key](#revoking-a-gpg-key) from your account.
To remove a GPG key from your account:
1. On the upper right corner, click on your avatar and go to your **Settings**.
1. Navigate to the **GPG keys** tab.
1. Click on the trash icon besides the GPG key you want to delete.
[ce-9546]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9546
# Signing commits with GPG
> [Introduced][ce-9546] in GitLab 9.5.
GitLab can show whether a commit is verified or not when signed with a GPG key.
All you need to do is upload the public GPG key in your profile settings.
GPG verified tags are not supported yet.
## Getting started with GPG
Here are a few guides to get you started with GPG:
- [Git Tools - Signing Your Work](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work)
- [Managing OpenPGP Keys](https://riseup.net/en/security/message-security/openpgp/gpg-keys)
- [OpenPGP Best Practices](https://riseup.net/en/security/message-security/openpgp/best-practices)
- [Creating a new GPG key with subkeys](https://www.void.gr/kargig/blog/2013/12/02/creating-a-new-gpg-key-with-subkeys/) (advanced)
## How GitLab handles GPG
GitLab uses its own keyring to verify the GPG signature. It does not access any
public key server.
In order to have a commit verified on GitLab the corresponding public key needs
to be uploaded to GitLab. For a signature to be verified two prerequisites need
to be met:
1. The public key needs to be added your GitLab account
1. One of the emails in the GPG key matches your **primary** email
## Generating a GPG key
If you don't already have a GPG key, the following steps will help you get
started:
1. [Install GPG](https://www.gnupg.org/download/index.html) for your operating system
1. Generate the private/public key pair with the following command:
```sh
gpg --full-gen-key
```
This will spawn a series of questions.
1. The first question is which algorithm can be used. Select the kind you want
or press <kbd>Enter</kbd> to choose the default (RSA and RSA):
```
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection? 1
```
1. The next question is key length. We recommend to choose the highest value
which is `4096`:
```
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 4096
Requested keysize is 4096 bits
```
1. Next, you need to specify the validity period of your key. This is something
subjective, and you can use the default value which is to never expire:
```
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0) 0
Key does not expire at all
```
1. Confirm that the answers you gave were correct by typing `y`:
```
Is this correct? (y/N) y
```
1. Enter you real name, the email address to be associated with this key (should
match the primary email address you use in GitLab) and an optional comment
(press <kbd>Enter</kbd> to skip):
```
GnuPG needs to construct a user ID to identify your key.
Real name: Mr. Robot
Email address: mr@robot.sh
Comment:
You selected this USER-ID:
"Mr. Robot <mr@robot.sh>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
```
1. Pick a strong password when asked and type it twice to confirm.
1. Use the following command to list the private GPG key you just created:
```
gpg --list-secret-keys mr@robot.sh
```
Replace `mr@robot.sh` with the email address you entered above.
1. Copy the GPG key ID that starts with `sec`. In the following example, that's
`0x30F2B65B9246B6CA`:
```
sec rsa4096/0x30F2B65B9246B6CA 2017-08-18 [SC]
D5E4F29F3275DC0CDA8FFC8730F2B65B9246B6CA
uid [ultimate] Mr. Robot <mr@robot.sh>
ssb rsa4096/0xB7ABC0813E4028C0 2017-08-18 [E]
```
1. Export the public key of that ID (replace your key ID from the previous step):
```
gpg --armor --export 0x30F2B65B9246B6CA
```
1. Finally, copy the public key and [add it in your profile settings](#adding-a-gpg-key-to-your-account)
## Adding a GPG key to your account
>**Note:**
Once you add a key, you cannot edit it, only remove it. In case the paste
didn't work, you'll have to remove the offending key and re-add it.
You can add a GPG key in your profile's settings:
1. On the upper right corner, click on your avatar and go to your **Settings**.
![Settings dropdown](../../../profile/img/profile_settings_dropdown.png)
1. Navigate to the **GPG keys** tab and paste your _public_ key in the 'Key'
box.
![Paste GPG public key](img/profile_settings_gpg_keys_paste_pub.png)
1. Finally, click on **Add key** to add it to GitLab. You will be able to see
its fingerprint, the corresponding email address and creation date.
![GPG key single page](img/profile_settings_gpg_keys_single_key.png)
## Associating your GPG key with Git
After you have [created your GPG key](#generating-a-gpg-key) and [added it to
your account](#adding-a-gpg-key-to-your-account), it's time to tell Git which
key to use.
1. Use the following command to list the private GPG key you just created:
```
gpg --list-secret-keys mr@robot.sh
```
Replace `mr@robot.sh` with the email address you entered above.
1. Copy the GPG key ID that starts with `sec`. In the following example, that's
`0x30F2B65B9246B6CA`:
```
sec rsa4096/0x30F2B65B9246B6CA 2017-08-18 [SC]
D5E4F29F3275DC0CDA8FFC8730F2B65B9246B6CA
uid [ultimate] Mr. Robot <mr@robot.sh>
ssb rsa4096/0xB7ABC0813E4028C0 2017-08-18 [E]
```
1. Tell Git to use that key to sign the commits:
```
git config --global user.signingkey 0x30F2B65B9246B6CA
```
Replace `0x30F2B65B9246B6CA` with your GPG key ID.
## Signing commits
After you have [created your GPG key](#generating-a-gpg-key) and [added it to
your account](#adding-a-gpg-key-to-your-account), you can start signing your
commits:
1. Commit like you used to, the only difference is the addition of the `-S` flag:
```
git commit -S -m "My commit msg"
```
1. Enter the passphrase of your GPG key when asked.
1. Push to GitLab and check that your commits [are verified](#verifying-commits).
If you don't want to type the `-S` flag every time you commit, you can tell Git
to sign your commits automatically:
```
git config --global commit.gpgsign true
```
## Verifying commits
1. Within a project or [merge request](../../merge_requests/index.md), navigate to
the **Commits** tab. Signed commits will show a badge containing either
"Verified" or "Unverified", depending on the verification status of the GPG
signature.
![Signed and unsigned commits](img/project_signed_and_unsigned_commits.png)
1. By clicking on the GPG badge, details of the signature are displayed.
![Signed commit with verified signature](img/project_signed_commit_verified_signature.png)
![Signed commit with verified signature](img/project_signed_commit_unverified_signature.png)
## Revoking a GPG key
Revoking a key **unverifies** already signed commits. Commits that were
verified by using this key will change to an unverified state. Future commits
will also stay unverified once you revoke this key. This action should be used
in case your key has been compromised.
To revoke a GPG key:
1. On the upper right corner, click on your avatar and go to your **Settings**.
1. Navigate to the **GPG keys** tab.
1. Click on **Revoke** besides the GPG key you want to delete.
## Removing a GPG key
Removing a key **does not unverify** already signed commits. Commits that were
verified by using this key will stay verified. Only unpushed commits will stay
unverified once you remove this key. To unverify already signed commits, you need
to [revoke the associated GPG key](#revoking-a-gpg-key) from your account.
To remove a GPG key from your account:
1. On the upper right corner, click on your avatar and go to your **Settings**.
1. Navigate to the **GPG keys** tab.
1. Click on the trash icon besides the GPG key you want to delete.
[ce-9546]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9546
...@@ -22,7 +22,7 @@ you to [connect with GitLab via SSH](../../../ssh/README.md). ...@@ -22,7 +22,7 @@ you to [connect with GitLab via SSH](../../../ssh/README.md).
## Files ## Files
## Create and edit files ### Create and edit files
Host your codebase in GitLab repositories by pushing your files to GitLab. Host your codebase in GitLab repositories by pushing your files to GitLab.
You can either use the user interface (UI), or connect your local computer You can either use the user interface (UI), or connect your local computer
...@@ -111,6 +111,8 @@ right from the UI. ...@@ -111,6 +111,8 @@ right from the UI.
- **Revert a commit:** - **Revert a commit:**
Easily [revert a commit](../merge_requests/revert_changes.md#reverting-a-commit) Easily [revert a commit](../merge_requests/revert_changes.md#reverting-a-commit)
from the UI to a selected branch. from the UI to a selected branch.
- **Sign a commit:**
Use GPG to [sign your commits](gpg_signed_commits/index.md).
## Repository size ## Repository size
......
@project_commits
Feature: Project Commits User Lookup
Background:
Given I sign in as a user
And I own a project
And I visit my project's commits page
Scenario: I browse commit from list
Given I have user with primary email
When I click on commit link
Then I see author based on primary email
Scenario: I browse another commit from list
Given I have user with secondary email
When I click on another commit link
Then I see author based on secondary email
@project-stars
Feature: Project Star
Scenario: New projects have 0 stars
Given public project "Community"
When I visit project "Community" page
Then The project has no stars
Scenario: Empty projects show star count
Given public empty project "Empty Public Project"
When I visit empty project page
Then The project has no stars
Scenario: Signed off users can't star projects
Given public project "Community"
And I visit project "Community" page
When I click on the star toggle button
Then I redirected to sign in page
@javascript
Scenario: Signed in users can toggle star
Given I sign in as "John Doe"
And public project "Community"
And I visit project "Community" page
When I click on the star toggle button
Then The project has 1 star
When I click on the star toggle button
Then The project has 0 stars
@javascript
Scenario: Star count sums stars
Given I sign in as "John Doe"
And public project "Community"
And I visit project "Community" page
And I click on the star toggle button
And I logout
And I sign in as "Mary Jane"
And I visit project "Community" page
When I click on the star toggle button
Then The project has 2 stars
class Spinach::Features::ProjectCommitsUserLookup < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
step 'I click on commit link' do
visit project_commit_path(@project, sample_commit.id)
end
step 'I click on another commit link' do
visit project_commit_path(@project, sample_commit.parent_id)
end
step 'I have user with primary email' do
user_primary
end
step 'I have user with secondary email' do
user_secondary
end
step 'I see author based on primary email' do
check_author_link(sample_commit.author_email, user_primary)
end
step 'I see author based on secondary email' do
check_author_link(sample_commit.author_email, user_secondary)
end
def check_author_link(email, user)
author_link = find('.commit-author-link')
expect(author_link['href']).to eq user_path(user)
expect(author_link['title']).to eq email
expect(find('.commit-author-name').text).to eq user.name
end
def user_primary
@user_primary ||= create(:user, email: 'dmitriy.zaporozhets@gmail.com')
end
def user_secondary
@user_secondary ||= begin
user = create(:user, email: 'dzaporozhets@example.com')
create(:email, { user: user, email: 'dmitriy.zaporozhets@gmail.com' })
user
end
end
end
class Spinach::Features::ProjectStar < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
include SharedUser
step "The project has no stars" do
expect(page).not_to have_content '.toggle-star'
end
step "The project has 0 stars" do
has_n_stars(0)
end
step "The project has 1 star" do
has_n_stars(1)
end
step "The project has 2 stars" do
has_n_stars(2)
end
# Requires @javascript
step "I click on the star toggle button" do
find(".star-btn", visible: true).click
end
step 'I redirected to sign in page' do
expect(current_path).to eq new_user_session_path
end
protected
def has_n_stars(n)
expect(page).to have_css(".star-count", text: n, visible: true)
end
end
...@@ -67,12 +67,14 @@ module API ...@@ -67,12 +67,14 @@ module API
end end
delete ":id/access_requests/:user_id" do delete ":id/access_requests/:user_id" do
source = find_source(source_type, params[:id]) source = find_source(source_type, params[:id])
member = source.requesters.find_by!(user_id: params[:user_id])
status 204 destroy_conditionally!(member) do
::Members::DestroyService.new(source, current_user, params) ::Members::DestroyService.new(source, current_user, params)
.execute(:requesters) .execute(:requesters)
end end
end end
end end
end end
end
end end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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