Commit 9bda56ad authored by Vladimir Shushlin's avatar Vladimir Shushlin Committed by Achilleas Pipinellis

Remove support for creating/updating release notes via tags API

We deprecated it a long time ago, so it's time to finally remove it

Changelog: removed
parent f3841248
---
name: remove_release_notes_from_tags_api
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/63392
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/290311
milestone: '14.0'
type: development
group: group::release
default_enabled: false
......@@ -123,7 +123,6 @@ Parameters:
| `tag_name` | string | yes | The name of a tag |
| `ref` | string | yes | Create tag using commit SHA, another tag name, or branch name |
| `message` | string | no | Creates annotated tag |
| `release_description` | string | no | This parameter is [deprecated](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/41766) for use in GitLab 11.7, and is planned for [removal](https://gitlab.com/gitlab-org/gitlab/-/issues/290311) in GitLab 14.0. Use the [Releases API](../api/releases/index.md) instead. |
```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/tags?tag_name=test&ref=master"
......@@ -149,10 +148,7 @@ Example response:
"committer_email": "jack@example.com",
"committed_date": "2012-05-28T04:42:42-07:00"
},
"release": {
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
},
"release": null,
"name": "v1.0.0",
"target": "2695effb5807a22ff3d138d593fd856244e155e7",
"message": null,
......@@ -182,82 +178,3 @@ Parameters:
| ---------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
| `tag_name` | string | yes | The name of a tag |
## Create a new release
WARNING:
This feature is in its end-of-life process. It is [deprecated](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/41766)
for use in GitLab 11.7, and is planned for [removal](https://gitlab.com/gitlab-org/gitlab/-/issues/290311)
in GitLab 14.0. Use the [Releases API](../api/releases/index.md) instead.
Add release notes to the existing Git tag. If there
already exists a release for the given tag, status code `409` is returned.
```plaintext
POST /projects/:id/repository/tags/:tag_name/release
```
Parameters:
| Attribute | Type | Required | Description |
| ---------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
| `tag_name` | string | yes | The name of a tag |
Request body:
- `description` (required) - Release notes with Markdown support
```json
{
"description": "Amazing release. Wow"
}
```
Response:
```json
{
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
}
```
## Update a release
WARNING:
This feature is in its end-of-life process. It is [deprecated](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/41766)
for use in GitLab 11.7, and is planned for [removal](https://gitlab.com/gitlab-org/gitlab/-/issues/290311)
in GitLab 14.0. Use the [Releases API](../api/releases/index.md) instead.
Updates the release notes of a given release.
```plaintext
PUT /projects/:id/repository/tags/:tag_name/release
```
Parameters:
| Attribute | Type | Required | Description |
| ---------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
| `tag_name` | string | yes | The name of a tag |
Request body:
- `description` (required) - Release notes with Markdown support
```json
{
"description": "Amazing release. Wow"
}
```
Response:
```json
{
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
}
```
......@@ -51,14 +51,12 @@ module API
end
desc 'Create a new repository tag' do
detail 'This optional release_description parameter was deprecated in GitLab 11.7.'
success Entities::Tag
end
params do
requires :tag_name, type: String, desc: 'The name of the tag'
requires :ref, type: String, desc: 'The commit sha or branch name'
optional :message, type: String, desc: 'Specifying a message creates an annotated tag'
optional :release_description, type: String, desc: 'Specifying release notes stored in the GitLab database (deprecated in GitLab 11.7)'
end
post ':id/repository/tags', :release_orchestration do
deprecate_release_notes unless params[:release_description].blank?
......@@ -69,19 +67,6 @@ module API
.execute(params[:tag_name], params[:ref], params[:message])
if result[:status] == :success
# Release creation with Tags API was deprecated in GitLab 11.7
if params[:release_description].present?
release_create_params = {
tag: params[:tag_name],
name: params[:tag_name], # Name can be specified in new API
description: params[:release_description]
}
::Releases::CreateService
.new(user_project, current_user, release_create_params)
.execute
end
present result[:tag],
with: Entities::Tag,
project: user_project
......@@ -111,82 +96,6 @@ module API
end
end
end
desc 'Add a release note to a tag' do
detail 'This feature was deprecated in GitLab 11.7.'
success Entities::TagRelease
end
params do
requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
requires :description, type: String, desc: 'Release notes with markdown support'
end
post ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS, feature_category: :release_orchestration do
deprecate_release_notes
authorize_create_release!
##
# Legacy API does not support tag auto creation.
not_found!('Tag') unless user_project.repository.find_tag(params[:tag])
release_create_params = {
tag: params[:tag],
name: params[:tag], # Name can be specified in new API
description: params[:description]
}
result = ::Releases::CreateService
.new(user_project, current_user, release_create_params)
.execute
if result[:status] == :success
present result[:release], with: Entities::TagRelease
else
render_api_error!(result[:message], result[:http_status])
end
end
desc "Update a tag's release note" do
detail 'This feature was deprecated in GitLab 11.7.'
success Entities::TagRelease
end
params do
requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
requires :description, type: String, desc: 'Release notes with markdown support'
end
put ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS, feature_category: :release_orchestration do
deprecate_release_notes
authorize_update_release!
result = ::Releases::UpdateService
.new(user_project, current_user, declared_params(include_missing: false))
.execute
if result[:status] == :success
present result[:release], with: Entities::TagRelease
else
render_api_error!(result[:message], result[:http_status])
end
end
end
helpers do
def authorize_create_release!
authorize! :create_release, user_project
end
def authorize_update_release!
authorize! :update_release, release
end
def release
@release ||= user_project.releases.find_by_tag(params[:tag])
end
def deprecate_release_notes
return unless Feature.enabled?(:remove_release_notes_from_tags_api, user_project, default_enabled: :yaml)
render_api_error!("Release notes modification via tags API is deprecated, see https://gitlab.com/gitlab-org/gitlab/-/issues/290311", 400)
end
end
end
end
......@@ -358,26 +358,6 @@ RSpec.describe API::Tags do
expect(json_response['message']).to eq('Target foo is invalid')
end
context 'when release_description is passed' do
it 'returns error' do
post api(route, current_user), params: { tag_name: tag_name, ref: 'master', release_description: 'Wow' }
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["message"]).to eq("Release notes modification via tags API is deprecated, see https://gitlab.com/gitlab-org/gitlab/-/issues/290311")
end
it 'creates a new tag with release if feature is enabled' do
stub_feature_flags(remove_release_notes_from_tags_api: false)
post api(route, current_user), params: { tag_name: tag_name, ref: 'master', release_description: 'Wow' }
expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/tag')
expect(json_response['name']).to eq(tag_name)
expect(json_response['release']['description']).to eq('Wow')
end
end
context 'annotated tag' do
it 'creates a new annotated tag' do
# Identity must be set in .gitconfig to create annotated tag.
......@@ -449,148 +429,4 @@ RSpec.describe API::Tags do
end
end
end
describe 'POST /projects/:id/repository/tags/:tag_name/release' do
let(:route) { "/projects/#{project_id}/repository/tags/#{tag_name}/release" }
let(:description) { 'Awesome release!' }
before do
stub_feature_flags(remove_release_notes_from_tags_api: false)
end
shared_examples_for 'repository new release' do
it 'creates description for existing git tag' do
post api(route, user), params: { description: description }
expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/release/tag_release')
expect(json_response['tag_name']).to eq(tag_name)
expect(json_response['description']).to eq(description)
end
it 'returns error if feature is removed' do
stub_feature_flags(remove_release_notes_from_tags_api: true)
post api(route, user), params: { description: description }
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["message"]).to eq("Release notes modification via tags API is deprecated, see https://gitlab.com/gitlab-org/gitlab/-/issues/290311")
end
context 'when tag does not exist' do
let(:tag_name) { 'unknown' }
it_behaves_like '404 response' do
let(:request) { post api(route, current_user), params: { description: description } }
let(:message) { '404 Tag Not Found' }
end
end
context 'when repository is disabled' do
include_context 'disabled repository'
it_behaves_like '403 response' do
let(:request) { post api(route, current_user), params: { description: description } }
end
end
end
context 'when authenticated', 'as a maintainer' do
let(:current_user) { user }
it_behaves_like 'repository new release'
context 'requesting with the escaped project full path' do
let(:project_id) { CGI.escape(project.full_path) }
it_behaves_like 'repository new release'
end
context 'on tag with existing release' do
let!(:release) { create(:release, :legacy, project: project, tag: tag_name, description: description) }
it 'returns 409 if there is already a release' do
post api(route, user), params: { description: description }
expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('Release already exists')
end
end
end
end
describe 'PUT id/repository/tags/:tag_name/release' do
let(:route) { "/projects/#{project_id}/repository/tags/#{tag_name}/release" }
let(:description) { 'Awesome release!' }
let(:new_description) { 'The best release!' }
before do
stub_feature_flags(remove_release_notes_from_tags_api: false)
end
shared_examples_for 'repository update release' do
context 'on tag with existing release' do
let!(:release) do
create(:release,
:legacy,
project: project,
tag: tag_name,
description: description)
end
it 'updates the release description' do
put api(route, current_user), params: { description: new_description }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['tag_name']).to eq(tag_name)
expect(json_response['description']).to eq(new_description)
end
it 'returns error if feature is removed' do
stub_feature_flags(remove_release_notes_from_tags_api: true)
put api(route, current_user), params: { description: new_description }
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["message"]).to eq("Release notes modification via tags API is deprecated, see https://gitlab.com/gitlab-org/gitlab/-/issues/290311")
end
end
context 'when tag does not exist' do
let(:tag_name) { 'unknown' }
it_behaves_like '403 response' do
let(:request) { put api(route, current_user), params: { description: new_description } }
let(:message) { '403 Forbidden' }
end
end
context 'when repository is disabled' do
include_context 'disabled repository'
it_behaves_like '403 response' do
let(:request) { put api(route, current_user), params: { description: new_description } }
end
end
end
context 'when authenticated', 'as a maintainer' do
let(:current_user) { user }
it_behaves_like 'repository update release'
context 'requesting with the escaped project full path' do
let(:project_id) { CGI.escape(project.full_path) }
it_behaves_like 'repository update release'
end
context 'when release does not exist' do
it_behaves_like '403 response' do
let(:request) { put api(route, current_user), params: { description: new_description } }
let(:message) { '403 Forbidden' }
end
end
end
end
end
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