Skip to content
Snippets Groups Projects
Unverified Commit 7c58b3d2 authored by Yorick Peterse's avatar Yorick Peterse
Browse files

Merge branch '11-7-stable' from GitLab.org

parents 64372c0f bbf5e923
No related branches found
No related tags found
No related merge requests found
Showing
with 279 additions and 46 deletions
Loading
Loading
@@ -4,16 +4,7 @@ class Projects::ReleasesController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
before_action :authorize_read_release!
before_action :check_releases_page_feature_flag
 
def index
end
private
def check_releases_page_feature_flag
return render_404 unless Feature.enabled?(:releases_page, @project)
push_frontend_feature_flag(:releases_page, @project)
end
end
Loading
Loading
@@ -550,15 +550,19 @@ class MergeRequest < ActiveRecord::Base
end
 
def diff_refs
if persisted?
merge_request_diff.diff_refs
else
Gitlab::Diff::DiffRefs.new(
base_sha: diff_base_sha,
start_sha: diff_start_sha,
head_sha: diff_head_sha
)
end
persisted? ? merge_request_diff.diff_refs : repository_diff_refs
end
# Instead trying to fetch the
# persisted diff_refs, this method goes
# straight to the repository to get the
# most recent data possible.
def repository_diff_refs
Gitlab::Diff::DiffRefs.new(
base_sha: branch_merge_base_sha,
start_sha: target_branch_sha,
head_sha: source_branch_sha
)
end
 
def branch_merge_base_sha
Loading
Loading
@@ -1098,9 +1102,10 @@ class MergeRequest < ActiveRecord::Base
end
 
def update_head_pipeline
self.head_pipeline = find_actual_head_pipeline
update_column(:head_pipeline_id, head_pipeline.id) if head_pipeline_id_changed?
find_actual_head_pipeline.try do |pipeline|
self.head_pipeline = pipeline
update_column(:head_pipeline_id, head_pipeline.id) if head_pipeline_id_changed?
end
end
 
def merge_request_pipeline_exists?
Loading
Loading
Loading
Loading
@@ -5,8 +5,7 @@ class Suggestion < ApplicationRecord
validates :note, presence: true
validates :commit_id, presence: true, if: :applied?
 
delegate :original_position, :position, :diff_file,
:noteable, to: :note
delegate :original_position, :position, :noteable, to: :note
 
def project
noteable.source_project
Loading
Loading
@@ -16,6 +15,15 @@ class Suggestion < ApplicationRecord
noteable.source_branch
end
 
def file_path
position.file_path
end
def diff_file
repository = project.repository
position.diff_file(repository)
end
# For now, suggestions only serve as a way to send patches that
# will change a single line (being able to apply multiple in the same place),
# which explains `from_line` and `to_line` being the same line.
Loading
Loading
Loading
Loading
@@ -11,6 +11,10 @@ module Suggestions
return error('Suggestion is not appliable')
end
 
unless latest_diff_refs?(suggestion)
return error('The file has been changed')
end
params = file_update_params(suggestion)
result = ::Files::UpdateService.new(suggestion.project, @current_user, params).execute
 
Loading
Loading
@@ -19,30 +23,44 @@ module Suggestions
end
 
result
rescue Files::UpdateService::FileChangedError
error('The file has been changed')
end
 
private
 
def file_update_params(suggestion)
diff_file = suggestion.diff_file
# Checks whether the latest diff refs for the branch matches with
# the position refs we're using to update the file content. Since
# the persisted refs are updated async (for MergeRequest),
# it's more consistent to fetch this data directly from the repository.
def latest_diff_refs?(suggestion)
suggestion.position.diff_refs == suggestion.noteable.repository_diff_refs
end
 
file_path = diff_file.file_path
branch_name = suggestion.noteable.source_branch
file_content = new_file_content(suggestion)
def file_update_params(suggestion)
blob = suggestion.diff_file.new_blob
file_path = suggestion.file_path
branch_name = suggestion.branch
file_content = new_file_content(suggestion, blob)
commit_message = "Apply suggestion to #{file_path}"
 
file_last_commit =
Gitlab::Git::Commit.last_for_path(suggestion.project.repository,
blob.commit_id,
blob.path)
{
file_path: file_path,
branch_name: branch_name,
start_branch: branch_name,
commit_message: commit_message,
file_content: file_content
file_content: file_content,
last_commit_sha: file_last_commit&.id
}
end
 
def new_file_content(suggestion)
def new_file_content(suggestion, blob)
range = suggestion.from_line_index..suggestion.to_line_index
blob = suggestion.diff_file.new_blob
 
blob.load_all_data!
content = blob.data.lines
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@
= link_to activity_project_path(@project), title: _('Activity'), class: 'shortcuts-project-activity' do
%span= _('Activity')
 
- if project_nav_tab?(:releases) && Feature.enabled?(:releases_page, @project)
- if project_nav_tab?(:releases)
= nav_link(controller: :releases) do
= link_to project_releases_path(@project), title: _('Releases'), class: 'shortcuts-project-releases' do
%span= _('Releases')
Loading
Loading
Loading
Loading
@@ -19,7 +19,7 @@
%ul
%li Project and wiki repositories
%li Project uploads
%li Project configuration including web hooks and services
%li Project configuration, including services
%li Issues with comments, merge requests with diffs and comments, labels, milestones, snippets, and other project entities
%li LFS objects
%p
Loading
Loading
@@ -28,6 +28,7 @@
%li Job traces and artifacts
%li Container registry images
%li CI variables
%li Webhooks
%li Any encrypted tokens
%p
Once the exported file is ready, you will receive a notification email with a download link, or you can download it from this page.
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@
= form.label :enabled, _('Active'), class: 'form-check-label'
.form-group
= form.label :api_url, _('Sentry API URL'), class: 'label-bold'
= form.url_field :api_url, class: 'form-control', placeholder: _('http://<sentry-host>/api/0/projects/{organization_slug}/{project_slug}/issues/')
= form.url_field :api_url, class: 'form-control', placeholder: _('http://<sentry-host>/api/0/projects/{organization_slug}/{project_slug}/')
%p.form-text.text-muted
= _('Enter your Sentry API URL')
.form-group
Loading
Loading
---
title: Fix unexpected exception by failure of finding an actual head pipeline
merge_request: 24257
author:
type: fixed
---
title: Update url placeholder for the sentry configuration page
merge_request: 24338
author:
type: other
---
title: Adjust applied suggestion reverting previous changes
merge_request: 24250
author:
type: fixed
---
title: Fix no avatar not showing in user selection box
merge_request: 24346
author:
type: fixed
Loading
Loading
@@ -217,6 +217,8 @@ repository from your GitLab server over HTTP.
 
## TLS support
 
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22602) in GitLab 11.7.
Gitaly supports TLS credentials for GRPC authentication. To be able to communicate
with a gitaly instance that listens for secure connections you will need to use `tls://` url
scheme in the `gitaly_address` of the corresponding storage entry in the gitlab configuration.
Loading
Loading
Loading
Loading
@@ -69,6 +69,9 @@ The following API resources are available:
- [Sidekiq metrics](sidekiq_metrics.md)
- [System hooks](system_hooks.md)
- [Tags](tags.md)
- [Releases](releases/index.md)
- Release Assets
- [Links](releases/links.md)
- [Todos](todos.md)
- [Users](users.md)
- [Validate CI configuration](lint.md) (linting)
Loading
Loading
# Releases API
 
> - [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/41766) in GitLab 11.7.
> - Using this API you can manipulate GitLab's [Release](../user/project/releases/index.md) entries.
> - Using this API you can manipulate GitLab's [Release](../../user/project/releases/index.md) entries.
> - For manipulating links as a release asset, see [Release Links API](links.md)
 
## List Releases
 
Loading
Loading
@@ -241,7 +242,7 @@ POST /projects/:id/releases
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding). |
| `name` | string | yes | The release name. |
| `tag_name` | string | yes | The tag where the release will be created from. |
| `description` | string | no | The description of the release. You can use [markdown](../user/markdown.md). |
| `description` | string | yes | The description of the release. You can use [markdown](../user/markdown.md). |
| `ref` | string | no | If `tag_name` doesn't exist, the release will be created from `ref`. It can be a commit SHA, another tag name, or a branch name. |
| `assets:links`| array of hash | no | An array of assets links. |
| `assets:links:name`| string | no (if `assets:links` specified, it's required) | The name of the link. |
Loading
Loading
@@ -331,8 +332,8 @@ PUT /projects/:id/releases/:tag_name
| Attribute | Type | Required | Description |
| ------------- | -------------- | -------- | --------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding). |
| `tag_name` | string | yes | The tag where the release will be created from. |
| `name` | string | no | The release name. |
| `tag_name` | string | no | The tag where the release will be created from. |
| `description` | string | no | The description of the release. You can use [markdown](../user/markdown.md). |
 
Example request:
Loading
Loading
# Release links API
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/41766) in GitLab 11.7.
Using this API you can manipulate GitLab's [Release](../../user/project/releases/index.md) links. For manipulating other Release assets, see [Release API](index.md).
## Get links
Get assets as links from a Release.
```
GET /projects/:id/releases/:tag_name/assets/links
```
| Attribute | Type | Required | Description |
| ------------- | -------------- | -------- | --------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding). |
| `tag_name` | string | yes | The tag associated with the Release. |
Example request:
```sh
curl --header "PRIVATE-TOKEN: gDybLx3yrUK_HLp3qPjS" "http://localhost:3000/api/v4/projects/24/releases/v0.1/assets/links"
```
Example response:
```json
[
{
"id":2,
"name":"awesome-v0.2.msi",
"url":"http://192.168.10.15:3000/msi",
"external":true
},
{
"id":1,
"name":"awesome-v0.2.dmg",
"url":"http://192.168.10.15:3000",
"external":true
}
]
```
## Get a link
Get an asset as a link from a Release.
```
GET /projects/:id/releases/:tag_name/assets/links/:link_id
```
| Attribute | Type | Required | Description |
| ------------- | -------------- | -------- | --------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding). |
| `tag_name` | string | yes | The tag associated with the Release. |
| `link_id` | integer | yes | The id of the link. |
Example request:
```sh
curl --header "PRIVATE-TOKEN: gDybLx3yrUK_HLp3qPjS" "http://localhost:3000/api/v4/projects/24/releases/v0.1/assets/links/1"
```
Example response:
```json
{
"id":1,
"name":"awesome-v0.2.dmg",
"url":"http://192.168.10.15:3000",
"external":true
}
```
## Create a link
Create an asset as a link from a Release.
```
POST /projects/:id/releases/:tag_name/assets/links
```
| Attribute | Type | Required | Description |
| ------------- | -------------- | -------- | --------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding). |
| `tag_name` | string | yes | The tag associated with the Release. |
| `name` | string | yes | The name of the link. |
| `url` | string | yes | The URL of the link. |
Example request:
```sh
curl --request POST \
--header "PRIVATE-TOKEN: gDybLx3yrUK_HLp3qPjS" \
--data name="awesome-v0.2.dmg" \
--data url="http://192.168.10.15:3000" \
"http://localhost:3000/api/v4/projects/24/releases/v0.1/assets/links"
```
Example response:
```json
{
"id":1,
"name":"awesome-v0.2.dmg",
"url":"http://192.168.10.15:3000",
"external":true
}
```
## Update a link
Update an asset as a link from a Release.
```
PUT /projects/:id/releases/:tag_name/assets/links/:link_id
```
| Attribute | Type | Required | Description |
| ------------- | -------------- | -------- | --------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding). |
| `tag_name` | string | yes | The tag associated with the Release. |
| `link_id` | integer | yes | The id of the link. |
| `name` | string | no | The name of the link. |
| `url` | string | no | The URL of the link. |
NOTE: **NOTE**
You have to specify at least one of `name` or `url`
Example request:
```sh
curl --request PUT --data name="new name" --header "PRIVATE-TOKEN: gDybLx3yrUK_HLp3qPjS" "http://localhost:3000/api/v4/projects/24/releases/v0.1/assets/links/1"
```
Example response:
```json
{
"id":1,
"name":"new name",
"url":"http://192.168.10.15:3000",
"external":true
}
```
## Delete a link
Delete an asset as a link from a Release.
```
DELETE /projects/:id/releases/:tag_name/assets/links/:link_id
```
| Attribute | Type | Required | Description |
| ------------- | -------------- | -------- | --------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding). |
| `tag_name` | string | yes | The tag associated with the Release. |
| `link_id` | integer | yes | The id of the link. |
Example request:
```sh
curl --request DELETE --header "PRIVATE-TOKEN: gDybLx3yrUK_HLp3qPjS" "http://localhost:3000/api/v4/projects/24/releases/v0.1/assets/links/1"
```
Example response:
```json
{
"id":1,
"name":"new name",
"url":"http://192.168.10.15:3000",
"external":true
}
```
Loading
Loading
@@ -12,7 +12,7 @@ GitLab's **Releases** are a way to track deliverables in your project. Consider
a snapshot in time of the source, build output, and other metadata or artifacts
associated with a released version of your code.
 
At the moment, you can create Release entries via the [Releases API](../../../api/releases.md);
At the moment, you can create Release entries via the [Releases API](../../../api/releases/index.md);
we recommend doing this as one of the last steps in your CI/CD release pipeline.
 
## Getting started with Releases
Loading
Loading
@@ -51,6 +51,9 @@ A link is any URL which can point to whatever you like; documentation, built
binaries, or other related materials. These can be both internal or external
links from your GitLab instance.
 
NOTE: **NOTE**
You can manipulate links of each release entry with [Release Links API](../../../api/releases/links.md)
## Releases list
 
Navigate to **Project > Releases** in order to see the list of releases for a given
Loading
Loading
Loading
Loading
@@ -61,7 +61,7 @@ The following items will be exported:
 
- Project and wiki repositories
- Project uploads
- Project configuration including web hooks and services
- Project configuration, including services
- Issues with comments, merge requests with diffs and comments, labels, milestones, snippets,
and other project entities
- LFS objects
Loading
Loading
Loading
Loading
@@ -8,8 +8,6 @@ module API
RELEASE_ENDPOINT_REQUIREMETS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS
.merge(tag_name: API::NO_SLASH_URL_PART_REGEX)
 
before { error!('404 Not Found', 404) unless Feature.enabled?(:releases_page, user_project) }
params do
requires :id, type: String, desc: 'The ID of a project'
end
Loading
Loading
Loading
Loading
@@ -7,7 +7,6 @@ module API
RELEASE_ENDPOINT_REQUIREMETS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS
.merge(tag_name: API::NO_SLASH_URL_PART_REGEX)
 
before { error!('404 Not Found', 404) unless Feature.enabled?(:releases_page, user_project) }
before { authorize_read_releases! }
 
params do
Loading
Loading
Loading
Loading
@@ -8,10 +8,7 @@ module Gitlab
 
def add_gon_variables
gon.api_version = 'v4'
gon.default_avatar_url =
Gitlab::Utils.append_path(
Gitlab.config.gitlab.url,
ActionController::Base.helpers.image_path('no_avatar.png'))
gon.default_avatar_url = default_avatar_url
gon.max_file_size = Gitlab::CurrentSettings.max_attachment_size
gon.asset_host = ActionController::Base.asset_host
gon.webpack_public_path = webpack_public_path
Loading
Loading
@@ -50,5 +47,15 @@ module Gitlab
# use this method to push multiple feature flags.
gon.push({ features: { var_name => enabled } }, true)
end
def default_avatar_url
# We can't use ActionController::Base.helpers.image_url because it
# doesn't return an actual URL because request is nil for some reason.
#
# We also can't use Gitlab::Utils.append_path because the image path
# may be an absolute URL.
URI.join(Gitlab.config.gitlab.url,
ActionController::Base.helpers.image_path('no_avatar.png')).to_s
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment