add: repo contributors

This commit is contained in:
vilet.yy 2021-03-18 16:35:40 +08:00
parent 25186b4e81
commit 6a7ef2a1a7
3 changed files with 22 additions and 0 deletions

View File

@ -106,6 +106,10 @@ class RepositoriesController < ApplicationController
@tags = Gitea::Repository::Tags::ListService.call(current_user&.gitea_token, @owner.login, @project.identifier, {page: params[:page], limit: params[:limit]})
end
def contributors
@contributors = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier)
end
def edit
return render_forbidden if !@project.manager?(current_user) && !current_user.admin?
end

View File

@ -0,0 +1,17 @@
total_count = @contributors.size
json.contributors @contributors.each do |contributor|
user = User.find_by(gitea_uid: contributor["id"])
if contributor["login"] == "root"
total_count -= 1
next
end
json.contributions contributor["contributions"]
json.gid contributor["id"]
json.login user.login
json.type user&.type
json.name user.real_name
json.image_url url_to_avatar(user)
end
json.total_count total_count

View File

@ -389,6 +389,7 @@ Rails.application.routes.draw do
match :sub_entries, :via => [:get, :put]
get :commits
get :tags
get :contributors
post :create_file
put :update_file
delete :delete_file