Show release notes in tag list

A release's tag reference is just the name of the tag, not the entire
tag object.

This also fixes the tags index if a tag's message contains non-UTF8 byte
sequences.
This commit is contained in:
Sean McGivern 2016-07-26 16:31:25 +01:00
parent 8a95f1f32c
commit e44bbcb994
3 changed files with 23 additions and 1 deletions

View file

@ -21,6 +21,7 @@ v 8.10.2 (unreleased)
- Fix backup restore. !5459 - Fix backup restore. !5459
- Rescue Rugged::OSError (lock exists) when creating references. !5497 - Rescue Rugged::OSError (lock exists) when creating references. !5497
- Disable MySQL foreign key checks before dropping all tables. !5472 - Disable MySQL foreign key checks before dropping all tables. !5472
- Show release notes in tags list
- Use project ID in repository cache to prevent stale data from persisting across projects. !5460 - Use project ID in repository cache to prevent stale data from persisting across projects. !5460
- Ensure relative paths for video are rewritten as we do for images. !5474 - Ensure relative paths for video are rewritten as we do for images. !5474
- Ensure current user can retry a build before showing the 'Retry' button. !5476 - Ensure current user can retry a build before showing the 'Retry' button. !5476

View file

@ -10,11 +10,12 @@ class Projects::TagsController < Projects::ApplicationController
@tags = @repository.tags_sorted_by(@sort) @tags = @repository.tags_sorted_by(@sort)
@tags = Kaminari.paginate_array(@tags).page(params[:page]) @tags = Kaminari.paginate_array(@tags).page(params[:page])
@releases = project.releases.where(tag: @tags) @releases = project.releases.where(tag: @tags.map(&:name))
end end
def show def show
@tag = @repository.find_tag(params[:id]) @tag = @repository.find_tag(params[:id])
@release = @project.releases.find_or_initialize_by(tag: @tag.name) @release = @project.releases.find_or_initialize_by(tag: @tag.name)
@commit = @repository.commit(@tag.target) @commit = @repository.commit(@tag.target)
end end

View file

@ -0,0 +1,20 @@
require 'spec_helper'
describe Projects::TagsController do
let(:project) { create(:project, :public) }
let!(:release) { create(:release, project: project) }
let!(:invalid_release) { create(:release, project: project, tag: 'does-not-exist') }
describe 'GET index' do
before { get :index, namespace_id: project.namespace.to_param, project_id: project.to_param }
it 'returns the tags for the page' do
expect(assigns(:tags).map(&:name)).to eq(['v1.1.0', 'v1.0.0'])
end
it 'returns releases matching those tags' do
expect(assigns(:releases)).to include(release)
expect(assigns(:releases)).not_to include(invalid_release)
end
end
end