diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 3410ddb3e..cd07803d6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -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 diff --git a/app/views/repositories/contributors.json.jbuilder b/app/views/repositories/contributors.json.jbuilder new file mode 100644 index 000000000..a5edb37e0 --- /dev/null +++ b/app/views/repositories/contributors.json.jbuilder @@ -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 + + diff --git a/config/routes.rb b/config/routes.rb index fd3b22ec9..9e9e3d7a8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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