|
- # 代码溯源 开始检测
- class Trace::CheckService < Trace::ClientService
-
- attr_accessor :token, :project, :if_branch, :branch_tag
-
- def initialize(token, project, if_branch, branch_tag)
- @token = token
- @project = project
- @if_branch = if_branch
- @branch_tag = branch_tag
- end
-
- def call
- result = http_authed_post(token, url, {data: request_params})
- reponse = render_response(result)
- end
-
- private
- def request_params
- repo = Gitea::Repository::GetService.call(project&.owner, project&.identifier)
- {
- product_name: Digest::MD5.hexdigest(project&.id.to_s)[0...20],
- product_type: project&.project_category&.name || '其他',
- code_type: project&.project_language&.name || '其他',
- product_desc: project&.description,
- git_url: repo['clone_url'],
- if_branch: if_branch,
- branch_tag: branch_tag
- }.compact
- end
-
- def url
- "/user/check".freeze
- end
- end
|