diff --git a/app/controllers/api/v1/projects/commits_controller.rb b/app/controllers/api/v1/projects/commits_controller.rb index 21987f4fb..98fdc290f 100644 --- a/app/controllers/api/v1/projects/commits_controller.rb +++ b/app/controllers/api/v1/projects/commits_controller.rb @@ -11,6 +11,9 @@ class Api::V1::Projects::CommitsController < Api::V1::BaseController end def recent - @result_object = Api::V1::Projects::Commits::RecentService.call(@project, {keyword: params[:keyword], page: page, limit: limit}, current_user&.gitea_token) + hash = Api::V1::Projects::Commits::RecentService.call(@project, {keyword: params[:keyword], page: page, limit: limit}, current_user&.gitea_token) + @result_object = hash[:result] + @object_detail = hash[:detail] + puts @object_detail end end \ No newline at end of file diff --git a/app/controllers/oauth/acge_controller.rb b/app/controllers/oauth/acge_controller.rb index efa5cca08..6f7c82039 100644 --- a/app/controllers/oauth/acge_controller.rb +++ b/app/controllers/oauth/acge_controller.rb @@ -30,7 +30,7 @@ class Oauth::AcgeController < Oauth::BaseController return else - username = uid[0..7] + username = uid password = SecureRandom.hex(4) reg_result = autologin_register(username, email, password, 'acge', phone, name) existing_rows = CSV.read("public/操作系统大赛用户信息.csv") diff --git a/app/services/api/v1/issues/update_service.rb b/app/services/api/v1/issues/update_service.rb index d55c0f586..c8050e6da 100644 --- a/app/services/api/v1/issues/update_service.rb +++ b/app/services/api/v1/issues/update_service.rb @@ -135,7 +135,7 @@ class Api::V1::Issues::UpdateService < ApplicationService end def build_previous_issue_changes - @previous_issue_changes.merge!(@updated_issue.previous_changes.slice("status_id", "priority_id", "fixed_version_id", "issue_tags_value", "branch_name", "subject", "description").symbolize_keys) + @previous_issue_changes.merge!(@updated_issue.previous_changes.slice("status_id", "priority_id", "fixed_version_id", "issue_tags_value", "branch_name", "subject").symbolize_keys) if @updated_issue.previous_changes[:start_date].present? @previous_issue_changes.merge!(start_date: [@updated_issue.previous_changes[:start_date][0].to_s, @updated_issue.previous_changes[:start_date][1].to_s]) end diff --git a/app/services/api/v1/projects/commits/recent_service.rb b/app/services/api/v1/projects/commits/recent_service.rb index 9bc77dfc2..9a226d9f2 100644 --- a/app/services/api/v1/projects/commits/recent_service.rb +++ b/app/services/api/v1/projects/commits/recent_service.rb @@ -1,7 +1,7 @@ class Api::V1::Projects::Commits::RecentService < ApplicationService attr_reader :project, :page, :limit, :keyword, :owner, :repo, :token - attr_accessor :gitea_data + attr_accessor :gitea_data, :gitea_repo_detail def initialize(project, params, token=nil) @project = project @@ -15,8 +15,9 @@ class Api::V1::Projects::Commits::RecentService < ApplicationService def call load_gitea_data + load_gitea_repo_detail - gitea_data + {result: gitea_data, detail:gitea_repo_detail} end private @@ -36,4 +37,8 @@ class Api::V1::Projects::Commits::RecentService < ApplicationService raise Error, "获取最近提交列表失败" unless @gitea_data.is_a?(Hash) end + def load_gitea_repo_detail + @gitea_repo_detail = $gitea_client.get_repos_by_owner_repo(owner, repo, {query: {access_token: token}}) + raise Error, "获取项目详情失败" unless @gitea_repo_detail.is_a?(Hash) + end end \ No newline at end of file diff --git a/app/views/api/v1/projects/commits/recent.json.jbuilder b/app/views/api/v1/projects/commits/recent.json.jbuilder index 2f954aadd..38a367d4c 100644 --- a/app/views/api/v1/projects/commits/recent.json.jbuilder +++ b/app/views/api/v1/projects/commits/recent.json.jbuilder @@ -1,4 +1,6 @@ json.total_count @result_object[:total_data].to_i +json.ssh_url @object_detail['ssh_url'] +json.clone_url @object_detail['clone_url'] json.commits @result_object[:data].each do |commit| json.sha commit['sha'] json.author do