Module: JPSClient::API::CommitLog

Included in:
Client
Defined in:
lib/jpsclient/api/commit_log.rb

Overview

提交记录管理相关 API 处理 /api/commit_log/* 路径的所有接口

Instance Method Summary collapse

Instance Method Details

#get_commit_log_list(params: {}) ⇒ Hash

获取提交记录列表

Parameters:

  • params (Hash) (defaults to: {})

    查询参数

Options Hash (params:):

  • :ids (Array<Integer>)

    提交记录ID数组

  • :workflowIds (Array<Integer>)

    工作流ID数组

  • :committers (Array<String>)

    提交者数组

  • :repoPath (String)

    仓库路径

  • :keyword (String)

    关键字

  • :remark (String)

    备注

  • :onlyCliff (Boolean)

    是否只显示cliff格式

  • :personalCenter (Boolean)

    是否个人中心

  • :pageNo (Integer)

    页码,默认1

  • :pageSize (Integer)

    每页数量,默认20

  • :startTimestamp (Integer)

    开始时间戳

  • :endTimestamp (Integer)

    结束时间戳

Returns:

  • (Hash)

    API响应

Raises:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/jpsclient/api/commit_log.rb', line 119

def get_commit_log_list(params: {})
  config = @request_config && @request_config["commit_log_list"]
  raise JPSClient::ExceptionError, "Missing config for commit_log_list" unless config && config["url"]
  path = config["url"]

  get_params = {
    pageNo: params[:pageNo] || 1,
    pageSize: params[:pageSize] || 20
  }

  # 添加可选的筛选参数(使用 Array() 支持单个值和数组)
  get_params[:ids] = Array(params[:ids]).join(',') if params[:ids]
  get_params[:workflowIds] = Array(params[:workflowIds]).join(',') if params[:workflowIds]
  get_params[:committers] = Array(params[:committers]).join(',') if params[:committers]
  get_params[:repoPath] = params[:repoPath] if params[:repoPath]
  get_params[:keyword] = params[:keyword] if params[:keyword]
  get_params[:remark] = params[:remark] if params[:remark]
  get_params[:onlyCliff] = params[:onlyCliff] if params.key?(:onlyCliff)
  get_params[:personalCenter] = params[:personalCenter] if params.key?(:personalCenter)
  get_params[:startTimestamp] = params[:startTimestamp] if params[:startTimestamp]
  get_params[:endTimestamp] = params[:endTimestamp] if params[:endTimestamp]

  return request_with_auth(:get, path, params: get_params)
end

#get_commit_log_preview(workflowId:, commitIds:, params: {}) ⇒ Hash

预览提交记录

Parameters:

  • workflowId (Integer)

    工作流ID(必需)

  • commitIds (Array<String>)

    提交ID数组(必需)

  • params (Hash) (defaults to: {})

    其他参数

Options Hash (params:):

  • :onlyCliff (Boolean)

    是否只显示cliff格式

Returns:

  • (Hash)

    API响应

Raises:



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/jpsclient/api/commit_log.rb', line 88

def get_commit_log_preview(workflowId:, commitIds:, params: {})
  config = @request_config && @request_config["commit_log_preview"]
  raise JPSClient::ExceptionError, "Missing config for commit_log_preview" unless config && config["url"]
  path = config["url"]

  get_params = {
    workflowId: workflowId,
    commitIds: commitIds.is_a?(Array) ? commitIds.join(',') : commitIds
  }

  get_params[:onlyCliff] = params[:onlyCliff] if params.key?(:onlyCliff)

  return request_with_auth(:get, path, params: get_params)
end

#get_commit_log_simple(commitId:) ⇒ Hash

获取提交记录简要信息

Parameters:

  • commitId (String)

    提交ID(必需)

Returns:

  • (Hash)

    API响应

Raises:



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/jpsclient/api/commit_log.rb', line 69

def get_commit_log_simple(commitId:)
  config = @request_config && @request_config["commit_log_simple"]
  raise JPSClient::ExceptionError, "Missing config for commit_log_simple" unless config && config["url"]
  path = config["url"]

  get_params = {
    commitId: commitId
  }

  return request_with_auth(:get, path, params: get_params)
end

#send_commit_log_message(projectId:, workflowId:, params: {}) ⇒ Hash

发送提交记录消息通知

Parameters:

  • projectId (String)

    项目ID(必需)

  • workflowId (Integer)

    工作流ID(必需)

  • params (Hash) (defaults to: {})

    其他参数

Options Hash (params:):

  • :single (Boolean)

    是否单个提交(默认 true)

  • :branch (String)

    分支名称(单数形式)

  • :branches (Array<String>)

    分支名称数组(向后兼容)

  • :commitIds (Array<String>)

    提交ID数组

  • :startTimestamp (Integer)

    开始时间戳

  • :endTimestamp (Integer)

    结束时间戳

  • :indexNo (Integer)

    索引号

Returns:

  • (Hash)

    API响应

Raises:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/jpsclient/api/commit_log.rb', line 43

def send_commit_log_message(projectId:, workflowId:, params: {})
  config = @request_config && @request_config["commit_log_send_message"]
  raise JPSClient::ExceptionError, "Missing config for commit_log_send_message" unless config && config["url"]
  path = config["url"]

  body_params = {
    projectId: projectId,
    workflowId: workflowId,
    single: params.fetch(:single, true)
  }

  # 添加可选参数
  body_params[:branch] = params[:branch] if params[:branch]               # 支持单数形式
  body_params[:branches] = params[:branches] if params[:branches]         # 向后兼容复数形式
  body_params[:commitIds] = params[:commitIds] if params[:commitIds]
  body_params[:startTimestamp] = params[:startTimestamp] if params[:startTimestamp]
  body_params[:endTimestamp] = params[:endTimestamp] if params[:endTimestamp]
  body_params[:indexNo] = params[:indexNo] if params[:indexNo]

  return request_with_auth(:post, path, body: body_params)
end

#update_commit_log(id:, params: {}) ⇒ Hash

更新提交记录

Parameters:

  • id (Integer)

    提交记录ID(必需)

  • params (Hash) (defaults to: {})

    更新参数

Options Hash (params:):

  • :description (String)

    描述

  • :fileUrls (Array<String>)

    文件URL数组

Returns:

  • (Hash)

    API响应

Raises:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jpsclient/api/commit_log.rb', line 14

def update_commit_log(id:, params: {})
  config = @request_config && @request_config["commit_log_update"]
  raise JPSClient::ExceptionError, "Missing config for commit_log_update" unless config && config["url"]
  path = config["url"]

  body_params = {
    id: id
  }

  # 添加可选参数
  body_params[:description] = params[:description] if params.key?(:description)
  body_params[:fileUrls] = params[:fileUrls] if params[:fileUrls]

  return request_with_auth(:post, path, body: body_params)
end