mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-22 04:35:45 +08:00
Merge branch 'develop' into standalone
This commit is contained in:
@@ -4,7 +4,7 @@ class Projects::ProjectUnitsController < Projects::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
if current_user.admin? || @project.owner?(current_user)
|
||||
if current_user.admin? || @project.manager?(current_user)
|
||||
ActiveRecord::Base.transaction do
|
||||
ProjectUnit.update_by_unit_types!(@project, unit_types)
|
||||
render_ok
|
||||
|
||||
@@ -17,7 +17,7 @@ class ProjectsController < ApplicationController
|
||||
menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops")
|
||||
menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions")
|
||||
menu.append(menu_hash_by_name("activity"))
|
||||
menu.append(menu_hash_by_name("setting")) if current_user.admin? || @project.owner?(current_user)
|
||||
menu.append(menu_hash_by_name("setting")) if current_user.admin? || @project.manager?(current_user)
|
||||
|
||||
render json: menu
|
||||
end
|
||||
@@ -111,7 +111,7 @@ class ProjectsController < ApplicationController
|
||||
end
|
||||
|
||||
def destroy
|
||||
if current_user.admin? || @project.owner?(current_user)
|
||||
if current_user.admin? || @project.manager?(current_user)
|
||||
ActiveRecord::Base.transaction do
|
||||
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call
|
||||
@project.destroy!
|
||||
|
||||
@@ -28,7 +28,7 @@ module RepositoriesHelper
|
||||
|
||||
def render_commit_author(author_json)
|
||||
return nil if author_json.blank?
|
||||
find_user_by_login author_json['login']
|
||||
find_user_by_login author_json['name']
|
||||
end
|
||||
|
||||
def readme_render_decode64_content(str, path)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
# Get a list of all commits from a repository
|
||||
class Gitea::Versions::ListService < Gitea::ClientService
|
||||
attr_reader :token, :user_name, :repo
|
||||
attr_reader :token, :user_name, :repo, :args
|
||||
|
||||
# sha: SHA or branch to start listing commits from (usually 'master')
|
||||
def initialize(token, user_name, repo)
|
||||
def initialize(token, user_name, repo, args={})
|
||||
@token = token
|
||||
@user_name = user_name
|
||||
@repo = repo
|
||||
@args = args
|
||||
end
|
||||
|
||||
def call
|
||||
@@ -16,7 +17,7 @@ class Gitea::Versions::ListService < Gitea::ClientService
|
||||
|
||||
private
|
||||
def params
|
||||
Hash.new.merge(token: token)
|
||||
args.merge(token: token)
|
||||
end
|
||||
|
||||
def url
|
||||
|
||||
@@ -37,7 +37,7 @@ class Repositories::DetailService < ApplicationService
|
||||
end
|
||||
|
||||
def release_suitable
|
||||
releases = Gitea::Versions::ListService.call(@owner.gitea_token, @owner.try(:login), @repo.try(:identifier))
|
||||
releases = Gitea::Versions::ListService.call(@owner.gitea_token, @owner.try(:login), @repo.try(:identifier), {page: 1, limit: 1})
|
||||
releases.is_a?(Hash) && releases[:status] == -1 ? [] : releases
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
json.author do
|
||||
if @project.forge?
|
||||
json.id user.id
|
||||
json.login user.login
|
||||
json.type user&.type
|
||||
json.name user.real_name
|
||||
|
||||
@@ -26,9 +26,9 @@ if @project.forge?
|
||||
end
|
||||
|
||||
json.author do
|
||||
json.partial! 'commit_author', user: render_commit_author(commit['author'])
|
||||
json.partial! 'commit_author', user: render_commit_author(commit['commit']['author']), name: commit['commit']['author']['name']
|
||||
end
|
||||
json.committer do
|
||||
json.partial! 'commit_author', user: render_commit_author(commit['committer'])
|
||||
json.partial! 'commit_author', user: render_commit_author(commit['commit']['committer']), name: commit['commit']['committer']['name']
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,5 +4,8 @@ if user
|
||||
json.name user.real_name
|
||||
json.image_url url_to_avatar(user)
|
||||
else
|
||||
json.nil!
|
||||
json.id nil
|
||||
json.login name
|
||||
json.name name
|
||||
json.image_url File.join("avatars/User","b")
|
||||
end
|
||||
|
||||
@@ -5,6 +5,7 @@ else
|
||||
json.total_count @hash_commit[:total_count]
|
||||
json.commits do
|
||||
json.array! @hash_commit[:body] do |commit|
|
||||
json.commit1 commit
|
||||
commiter = commit['committer']
|
||||
if commiter.present?
|
||||
commit_user_id = commiter['id']
|
||||
@@ -17,7 +18,13 @@ else
|
||||
if forge_user
|
||||
json.partial! 'author', user: forge_user
|
||||
else
|
||||
json.author nil
|
||||
json.author do
|
||||
json.id nil
|
||||
json.login commit['commit']['author']['name']
|
||||
json.type nil
|
||||
json.name commit['commit']['author']['name']
|
||||
json.image_url File.join("avatars/User","b")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ json.release_versions do
|
||||
json.tag_name release["tag_name"]
|
||||
json.created_at format_time(release["created_at"].to_time)
|
||||
end
|
||||
json.total_count @result[:release].size
|
||||
json.total_count @repository&.version_releases.size
|
||||
end
|
||||
json.branches do
|
||||
json.list @result[:branch].each do |branch|
|
||||
@@ -93,3 +93,5 @@ json.contributors do
|
||||
json.total_count total_count
|
||||
end
|
||||
json.languages @result[:language]
|
||||
|
||||
json.partial! 'author', locals: { user: @project.owner }
|
||||
|
||||
Reference in New Issue
Block a user