Skip to content

Commit

Permalink
Add latest changes from gitlab-org/gitlab@master
Browse files Browse the repository at this point in the history
  • Loading branch information
GitLab Bot committed Dec 1, 2020
1 parent 2ddcd63 commit 259aa13
Show file tree
Hide file tree
Showing 21 changed files with 526 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { escape, capitalize } from 'lodash';
import { GlLoadingIcon } from '@gitlab/ui';
import StageColumnComponentLegacy from './stage_column_component_legacy.vue';
import GraphWidthMixin from '../../mixins/graph_width_mixin';
import LinkedPipelinesColumn from './linked_pipelines_column.vue';
import LinkedPipelinesColumnLegacy from './linked_pipelines_column_legacy.vue';
import GraphBundleMixin from '../../mixins/graph_pipeline_bundle_mixin';
import { UPSTREAM, DOWNSTREAM, MAIN } from './constants';
export default {
name: 'PipelineGraphLegacy',
components: {
StageColumnComponentLegacy,
GlLoadingIcon,
LinkedPipelinesColumn,
LinkedPipelinesColumnLegacy,
StageColumnComponentLegacy,
},
mixins: [GraphWidthMixin, GraphBundleMixin],
props: {
Expand Down Expand Up @@ -204,7 +204,7 @@ export default {
@refreshPipelineGraph="requestRefreshPipelineGraph"
/>
<linked-pipelines-column
<linked-pipelines-column-legacy
v-if="hasUpstream"
:type="$options.upstream"
:linked-pipelines="upstreamPipelines"
Expand Down Expand Up @@ -240,7 +240,7 @@ export default {
/>
</ul>
<linked-pipelines-column
<linked-pipelines-column-legacy
v-if="hasDownstream"
:type="$options.downstream"
:linked-pipelines="downstreamPipelines"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<script>
import LinkedPipeline from './linked_pipeline.vue';
import { UPSTREAM } from './constants';
export default {
components: {
LinkedPipeline,
},
props: {
columnTitle: {
type: String,
required: true,
},
linkedPipelines: {
type: Array,
required: true,
},
type: {
type: String,
required: true,
},
projectId: {
type: Number,
required: true,
},
},
computed: {
columnClass() {
const positionValues = {
right: 'gl-ml-11',
left: 'gl-mr-7',
};
return `graph-position-${this.graphPosition} ${positionValues[this.graphPosition]}`;
},
graphPosition() {
return this.isUpstream ? 'left' : 'right';
},
// Refactor string match when BE returns Upstream/Downstream indicators
isUpstream() {
return this.type === UPSTREAM;
},
},
methods: {
onPipelineClick(downstreamNode, pipeline, index) {
this.$emit('linkedPipelineClick', pipeline, index, downstreamNode);
},
onDownstreamHovered(jobName) {
this.$emit('downstreamHovered', jobName);
},
onPipelineExpandToggle(jobName, expanded) {
// Highlighting only applies to downstream pipelines
if (this.isUpstream) {
return;
}
this.$emit('pipelineExpandToggle', jobName, expanded);
},
},
};
</script>

<template>
<div :class="columnClass" class="stage-column linked-pipelines-column">
<div class="stage-name linked-pipelines-column-title">{{ columnTitle }}</div>
<div v-if="isUpstream" class="cross-project-triangle"></div>
<ul>
<linked-pipeline
v-for="(pipeline, index) in linkedPipelines"
:key="pipeline.id"
:class="{
active: pipeline.isExpanded,
'left-connector': pipeline.isExpanded && graphPosition === 'left',
}"
:pipeline="pipeline"
:column-title="columnTitle"
:project-id="projectId"
:type="type"
@pipelineClicked="onPipelineClick($event, pipeline, index)"
@downstreamHovered="onDownstreamHovered"
@pipelineExpandToggle="onPipelineExpandToggle"
/>
</ul>
</div>
</template>
2 changes: 1 addition & 1 deletion app/models/merge_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ def check_mergeability(async: false)
# rubocop: enable CodeReuse/ServiceClass

def diffable_merge_ref?
merge_ref_head.present? && (Feature.enabled?(:display_merge_conflicts_in_diff, project) || can_be_merged?)
open? && merge_ref_head.present? && (Feature.enabled?(:display_merge_conflicts_in_diff, project) || can_be_merged?)
end

# Returns boolean indicating the merge_status should be rechecked in order to
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Paginate first page of branches using Gitaly
merge_request: 48595
author:
type: performance
3 changes: 2 additions & 1 deletion doc/api/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ GET /users
]
```

Users on GitLab [Starter, Bronze, or higher](https://about.gitlab.com/pricing/) also see the `shared_runners_minutes_limit`, and `extra_shared_runners_minutes_limit` parameters.
Users on GitLab [Starter, Bronze, or higher](https://about.gitlab.com/pricing/) also see the `shared_runners_minutes_limit`, `extra_shared_runners_minutes_limit`, and `using_license_seat` parameters.

```json
[
Expand All @@ -179,6 +179,7 @@ Users on GitLab [Starter, Bronze, or higher](https://about.gitlab.com/pricing/)
...
"shared_runners_minutes_limit": 133,
"extra_shared_runners_minutes_limit": 133,
"using_license_seat": true
...
}
]
Expand Down
2 changes: 1 addition & 1 deletion doc/gitlab-basics/start-using-git.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ To add a remote repository to your local copy:
1. On your computer, open the terminal in the directory you've initialized, paste the command you copied, and press <kbd>enter</kbd>:

```shell
git remote add origin <git@gitlab.com:username/projectpath.git
git remote add origin git@gitlab.com:username/projectpath.git
```

After you've done that, you can [stage your files](#add-and-commit-local-changes) and [upload them to GitLab](#send-changes-to-gitlabcom).
Expand Down
2 changes: 2 additions & 0 deletions doc/university/training/topics/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ git tag my_lightweight_tag

# Annotated tag
git tag -a v1.0 -m ‘Version 1.0’

# Show list of the existing tags
git tag

git push origin --tags
Expand Down
2 changes: 2 additions & 0 deletions lib/gitlab/github_import/importer/lfs_objects_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def each_object_to_import
lfs_objects.each do |object|
yield object
end
rescue StandardError => e
error(project.id, e)
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/gitlab/github_import/parallel_scheduling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def execute
retval
rescue => e
error(project.id, e)

raise e
end

# Imports all the objects in sequence in the current thread.
Expand Down Expand Up @@ -178,7 +180,7 @@ def error(project_id, exception)
)
)

Gitlab::ErrorTracking.track_and_raise_exception(
Gitlab::ErrorTracking.track_exception(
exception,
log_attributes(project_id)
)
Expand Down
19 changes: 19 additions & 0 deletions lib/gitlab/pagination/gitaly_keyset_pager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def initialize(request_context, project)
# and supports pagination via gitaly.
def paginate(finder)
return paginate_via_gitaly(finder) if keyset_pagination_enabled?
return paginate_first_page_via_gitaly(finder) if paginate_first_page?

branches = ::Kaminari.paginate_array(finder.execute)
Gitlab::Pagination::OffsetPagination
Expand All @@ -28,12 +29,30 @@ def keyset_pagination_enabled?
Feature.enabled?(:branch_list_keyset_pagination, project) && params[:pagination] == 'keyset'
end

def paginate_first_page?
Feature.enabled?(:branch_list_keyset_pagination, project) && (params[:page].blank? || params[:page].to_i == 1)
end

def paginate_via_gitaly(finder)
finder.execute(gitaly_pagination: true).tap do |records|
apply_headers(records)
end
end

# When first page is requested, we paginate the data via Gitaly
# Headers are added to immitate offset pagination, while it is the default option
def paginate_first_page_via_gitaly(finder)
finder.execute(gitaly_pagination: true).tap do |records|
total = project.repository.branch_count
per_page = params[:per_page].presence || Kaminari.config.default_per_page

Gitlab::Pagination::OffsetHeaderBuilder.new(
request_context: request_context, per_page: per_page, page: 1, next_page: 2,
total: total, total_pages: total / per_page + 1
).execute
end
end

def apply_headers(records)
if records.count == params[:per_page]
Gitlab::Pagination::Keyset::HeaderBuilder
Expand Down
65 changes: 65 additions & 0 deletions lib/gitlab/pagination/offset_header_builder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# frozen_string_literal: true

module Gitlab
module Pagination
class OffsetHeaderBuilder
attr_reader :request_context, :per_page, :page, :next_page, :prev_page, :total, :total_pages

delegate :params, :header, :request, to: :request_context

def initialize(request_context:, per_page:, page:, next_page:, prev_page: nil, total:, total_pages:)
@request_context = request_context
@per_page = per_page
@page = page
@next_page = next_page
@prev_page = prev_page
@total = total
@total_pages = total_pages
end

def execute(exclude_total_headers: false, data_without_counts: false)
header 'X-Per-Page', per_page.to_s
header 'X-Page', page.to_s
header 'X-Next-Page', next_page.to_s
header 'X-Prev-Page', prev_page.to_s
header 'Link', pagination_links(data_without_counts)

return if exclude_total_headers || data_without_counts

header 'X-Total', total.to_s
header 'X-Total-Pages', total_pages.to_s
end

private

def pagination_links(data_without_counts)
[].tap do |links|
links << %(<#{page_href(page: prev_page)}>; rel="prev") if prev_page
links << %(<#{page_href(page: next_page)}>; rel="next") if next_page
links << %(<#{page_href(page: 1)}>; rel="first")

links << %(<#{page_href(page: total_pages)}>; rel="last") unless data_without_counts
end.join(', ')
end

def base_request_uri
@base_request_uri ||= URI.parse(request.url).tap do |uri|
uri.host = Gitlab.config.gitlab.host
uri.port = Gitlab.config.gitlab.port
end
end

def build_page_url(query_params:)
base_request_uri.tap do |uri|
uri.query = query_params
end.to_s
end

def page_href(next_page_params = {})
query_params = params.merge(**next_page_params, per_page: params[:per_page]).to_query

build_page_url(query_params: query_params)
end
end
end
end
54 changes: 11 additions & 43 deletions lib/gitlab/pagination/offset_pagination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,58 +48,26 @@ def add_default_order(relation)
end

def add_pagination_headers(paginated_data, exclude_total_headers)
header 'X-Per-Page', paginated_data.limit_value.to_s
header 'X-Page', paginated_data.current_page.to_s
header 'X-Next-Page', paginated_data.next_page.to_s
header 'X-Prev-Page', paginated_data.prev_page.to_s
header 'Link', pagination_links(paginated_data)

return if exclude_total_headers || data_without_counts?(paginated_data)

header 'X-Total', paginated_data.total_count.to_s
header 'X-Total-Pages', total_pages(paginated_data).to_s
end

def pagination_links(paginated_data)
[].tap do |links|
links << %(<#{page_href(page: paginated_data.prev_page)}>; rel="prev") if paginated_data.prev_page
links << %(<#{page_href(page: paginated_data.next_page)}>; rel="next") if paginated_data.next_page
links << %(<#{page_href(page: 1)}>; rel="first")

links << %(<#{page_href(page: total_pages(paginated_data))}>; rel="last") unless data_without_counts?(paginated_data)
end.join(', ')
end

def total_pages(paginated_data)
# Ensure there is in total at least 1 page
[paginated_data.total_pages, 1].max
Gitlab::Pagination::OffsetHeaderBuilder.new(
request_context: self, per_page: paginated_data.limit_value, page: paginated_data.current_page,
next_page: paginated_data.next_page, prev_page: paginated_data.prev_page,
total: total_count(paginated_data), total_pages: total_pages(paginated_data)
).execute(exclude_total_headers: exclude_total_headers, data_without_counts: data_without_counts?(paginated_data))
end

def data_without_counts?(paginated_data)
paginated_data.is_a?(Kaminari::PaginatableWithoutCount)
end

def base_request_uri
@base_request_uri ||= URI.parse(request.url).tap do |uri|
uri.host = Gitlab.config.gitlab.host
uri.port = Gitlab.config.gitlab.port
end
def total_count(paginated_data)
paginated_data.total_count unless data_without_counts?(paginated_data)
end

def build_page_url(query_params:)
base_request_uri.tap do |uri|
uri.query = query_params
end.to_s
end

def page_href(next_page_params = {})
query_params = params.merge(**next_page_params, per_page: per_page).to_query

build_page_url(query_params: query_params)
end
def total_pages(paginated_data)
return if data_without_counts?(paginated_data)

def per_page
@per_page ||= params[:per_page]
# Ensure there is in total at least 1 page
[paginated_data.total_pages, 1].max
end
end
end
Expand Down
Loading

0 comments on commit 259aa13

Please sign in to comment.