diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 7e29c126d..f7a6ce76b 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -174,7 +174,7 @@ class PullRequestsController < ApplicationController end def show - @user_permission = current_user.present? && current_user.logged? && (@issue.assigned_to_id == current_user.id || current_user.admin? ) + @user_permission = current_user.present? && current_user.logged? && (@issue.assigned_to_id == current_user.id || @project.user_id == current_user.id || @project.manager?(current_user) ) @issue_user = @issue.user @issue_assign_to = @issue.get_assign_user diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 59699c27b..65c2f404c 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -97,7 +97,7 @@ class RepositoriesController < ApplicationController end def sync_mirror - return render_error("正在镜像中..") if @repo.mirror.warning? + return render_error("正在镜像中..") if @repo.mirror.waiting? @repo.sync_mirror! SyncMirroredRepositoryJob.perform_later(@repo.id, current_user.id) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 19ef7f9de..2b6d9d405 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -14,6 +14,12 @@ module RepositoriesHelper default_type.include?(str&.downcase) end + def is_readme_type?(str) + return false if str.blank? + readme_types = ["readme.md", "readme", "readme_en.md", "readme_zh.md", "readme_en", "readme_zh"] + readme_types.include?(str.to_s.downcase) + end + def render_commit_author(author_json) return nil if author_json.blank? find_user_by_login author_json['login'] diff --git a/app/services/projects/fork_service.rb b/app/services/projects/fork_service.rb index f2cdca409..3efd3e43c 100644 --- a/app/services/projects/fork_service.rb +++ b/app/services/projects/fork_service.rb @@ -21,6 +21,7 @@ class Projects::ForkService < ApplicationService new_repository = clone_project.repository new_repository.user = @target_owner + new_repository.identifier = @project.identifier new_repository.save! result = Gitea::Repository::ForkService.new(@project.owner, @target_owner, @project.identifier, @organization).call diff --git a/app/views/repositories/_simple_entry.json.jbuilder b/app/views/repositories/_simple_entry.json.jbuilder index cdea42c8b..4890f4047 100644 --- a/app/views/repositories/_simple_entry.json.jbuilder +++ b/app/views/repositories/_simple_entry.json.jbuilder @@ -12,7 +12,7 @@ json.target entry['target'] json.download_url entry['download_url'] json.direct_download direct_download json.image_type image_type - +json.is_readme_file is_readme_type?(file_name) if entry['latest_commit'] json.partial! 'last_commit', entry: entry end diff --git a/app/views/repositories/entries.json.jbuilder b/app/views/repositories/entries.json.jbuilder index 7c7b5ef70..7b2c7c6e6 100644 --- a/app/views/repositories/entries.json.jbuilder +++ b/app/views/repositories/entries.json.jbuilder @@ -18,12 +18,15 @@ json.entries do json.type entry['type'] json.size entry['size'] content = - if entry['name'] === 'README.md' + if is_readme_type?(entry['name']) + is_readme_file = true content = Gitea::Repository::Entries::GetService.call(@project_owner, @project.identifier, entry['name'], ref: @ref)['content'] readme_render_decode64_content(content, @path) else + is_readme_file = false entry['content'] end + json.is_readme_file is_readme_file json.content content json.target entry['target'] if entry['latest_commit']