新增:流水线分支信息

This commit is contained in:
yystopf 2025-09-25 11:00:56 +08:00
parent 581787e8c5
commit faff7122a6
2 changed files with 4 additions and 3 deletions

View File

@ -1,10 +1,10 @@
class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::BaseController
def index
@files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows") rescue []
@files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows", {query: {ref: params[:ref]}}) rescue []
@has_file = @files.select { |i| i['name'] == params[:workflow] }.present?
if @has_file
@result_object = Api::V1::Projects::Actions::Runs::ListService.call(@project, {workflow: params[:workflow], page: page, limit: limit}, current_user&.gitea_token)
@result_object = Api::V1::Projects::Actions::Runs::ListService.call(@project, {workflow: params[:workflow], page: page, limit: limit, ref: params[:ref]}, current_user&.gitea_token)
@begin_num = (page.to_i - 1) * limit.to_i
end
end

View File

@ -1,7 +1,7 @@
class Api::V1::Projects::Actions::Runs::ListService < ApplicationService
include ActiveModel::Model
attr_reader :project, :token, :owner, :repo, :workflow, :page, :limit
attr_reader :project, :token, :owner, :repo, :workflow, :ref, :page, :limit
attr_accessor :gitea_data
validates :workflow, presence: true
@ -11,6 +11,7 @@ class Api::V1::Projects::Actions::Runs::ListService < ApplicationService
@owner = project&.owner.login
@repo = project&.identifier
@workflow = params[:workflow]
@ref = params[:ref]
@page = params[:page] || 1
@limit = params[:limit] || 15
@token = token