pindo 5.20.4 → 5.20.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pindo/module/pgyer/pgyerhelper.rb +173 -84
- data/lib/pindo/module/source_files_guard.rb +12 -3
- data/lib/pindo/module/task/model/jps/jps_bind_package_task.rb +41 -15
- data/lib/pindo/module/task/model/nuget/nuget_upload_task.rb +6 -2
- data/lib/pindo/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c0edb06546cd16285c138448253905ee5649e4e171af1a13cfbb61942f169e03
|
|
4
|
+
data.tar.gz: 88760601ffcc0a1863d537a8e1bf5a7f26f7ddb840b96831825e3699a26d2f5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c35bf1529656b6a5a24a2e727db177943ce3ab78a3fcc837a985b4584a62e1512897430e6520c4eaf146bc2a7b3c8ba6fca8d9e1af270826b31f0a070f81a8da
|
|
7
|
+
data.tar.gz: 4a9ecf6b0f98d988ca930c660d7082f0fe266698934926238482577cef0cd4c1f594ef686532a61aafa7a3cbb046aead11fa776da7a444344362b881d6d0e607
|
|
@@ -198,8 +198,6 @@ module Pindo
|
|
|
198
198
|
|
|
199
199
|
puts "package_type #{package_type} manage_type: #{manage_type}"
|
|
200
200
|
|
|
201
|
-
Funlog.instance.fancyinfo_success("获取工作流列表成功,共 #{workflows.size} 个工作流")
|
|
202
|
-
|
|
203
201
|
# 2. 根据 manage_type 或 package_type 过滤工作流
|
|
204
202
|
if manage_type == "git"
|
|
205
203
|
# manage_type 为 git 时,只筛选 manage_type == "git" 的工作流,不看 package_type
|
|
@@ -249,6 +247,10 @@ module Pindo
|
|
|
249
247
|
display_workflows = filtered_workflows
|
|
250
248
|
end
|
|
251
249
|
|
|
250
|
+
# 过滤后再报数:只报总数会让人以为剩下的工作流被漏掉了,
|
|
251
|
+
# 实际是按 manage_type / package_type 筛掉的,两个数字一起给出才不歧义
|
|
252
|
+
Funlog.instance.fancyinfo_success("获取工作流列表成功,共 #{workflows.size} 个工作流,其中 #{type_desc} #{display_workflows.size} 个")
|
|
253
|
+
|
|
252
254
|
# 2.5 若指定了 workflow_name,按名称精确匹配(忽略大小写与首尾空格)确定性选择。
|
|
253
255
|
# 只接受完整精确匹配,不做子串模糊匹配,避免 "Production" 误命中 "Legacy Production Upload"。
|
|
254
256
|
if workflow_name && !workflow_name.to_s.strip.empty? && !display_workflows.empty?
|
|
@@ -849,6 +851,16 @@ module Pindo
|
|
|
849
851
|
|
|
850
852
|
# 计算上传耗时
|
|
851
853
|
upload_duration = Time.now - upload_start_time
|
|
854
|
+
|
|
855
|
+
# upload_file 失败时返回 nil。不在这里拦住的话,后面会照常打印「上传完成」
|
|
856
|
+
# 和一个拿完整文件大小除以失败耗时算出来的假速度,再去做无谓的附件上传,
|
|
857
|
+
# 直到提交包信息前才失败——日志里先 ❌ 后 ✅ 就是这么来的。
|
|
858
|
+
if upload_res.nil?
|
|
859
|
+
Funlog.instance.fancyinfo_error("文件上传失败! 耗时: #{upload_duration.round(2)} 秒")
|
|
860
|
+
puts " 失败原因见上方日志;加 --verbose 重跑可看到接口返回的 code/msg"
|
|
861
|
+
raise Informative, "上传失败!"
|
|
862
|
+
end
|
|
863
|
+
|
|
852
864
|
upload_speed = file_size_mb / upload_duration
|
|
853
865
|
puts "✅ 文件上传完成! 耗时: #{upload_duration.round(2)} 秒, 平均速度: #{upload_speed.round(2)} MB/s"
|
|
854
866
|
|
|
@@ -865,8 +877,15 @@ module Pindo
|
|
|
865
877
|
|
|
866
878
|
# 计算附件上传耗时
|
|
867
879
|
attach_duration = Time.now - attach_start_time
|
|
868
|
-
|
|
869
|
-
|
|
880
|
+
|
|
881
|
+
# 同主文件:nil 即失败,不能照打「上传完成」。
|
|
882
|
+
# 但附件失败不阻断主包流程(下方 rescue 也是这个取向),只如实报告。
|
|
883
|
+
if attach_key_url.nil?
|
|
884
|
+
Funlog.instance.fancyinfo_warning("附件上传失败! 耗时: #{attach_duration.round(2)} 秒(不影响主包上传)")
|
|
885
|
+
else
|
|
886
|
+
attach_speed = attach_size_mb / attach_duration
|
|
887
|
+
puts "✅ 附件上传完成! 耗时: #{attach_duration.round(2)} 秒, 平均速度: #{attach_speed.round(2)} MB/s"
|
|
888
|
+
end
|
|
870
889
|
end
|
|
871
890
|
|
|
872
891
|
if !attach_key_url.nil?
|
|
@@ -1106,10 +1125,11 @@ module Pindo
|
|
|
1106
1125
|
# @param git_commit_id [String] Git commit SHA
|
|
1107
1126
|
# @param workflow_id [Integer] 工作流ID(可选)
|
|
1108
1127
|
# @return [Hash, nil] commit_log 记录或 nil
|
|
1109
|
-
def find_commit_log_by_git_commit_id(git_commit_id, workflow_id = nil)
|
|
1128
|
+
def find_commit_log_by_git_commit_id(git_commit_id, workflow_id = nil, branch = nil)
|
|
1110
1129
|
params = {
|
|
1111
1130
|
pageNo: 1,
|
|
1112
|
-
pageSize: 50 # 查询最近的 50 条记录
|
|
1131
|
+
pageSize: 50, # 查询最近的 50 条记录
|
|
1132
|
+
onlyCliff: false
|
|
1113
1133
|
}
|
|
1114
1134
|
|
|
1115
1135
|
# 如果指定了 workflow_id,添加到筛选条件
|
|
@@ -1121,26 +1141,16 @@ module Pindo
|
|
|
1121
1141
|
if list_result && list_result["data"] && list_result["data"]["details"]
|
|
1122
1142
|
details = list_result["data"]["details"]
|
|
1123
1143
|
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
if item_commit_id == git_commit_id
|
|
1132
|
-
true
|
|
1133
|
-
# 前缀匹配(支持 git 短 SHA,如 9e959ffd)
|
|
1134
|
-
elsif git_commit_id.length >= 7 && item_commit_id.start_with?(git_commit_id)
|
|
1135
|
-
true
|
|
1136
|
-
elsif git_commit_id.length >= 7 && git_commit_id.start_with?(item_commit_id)
|
|
1137
|
-
true
|
|
1138
|
-
else
|
|
1139
|
-
false
|
|
1140
|
-
end
|
|
1144
|
+
matched_logs = details.select { |item| same_commit?(item["commitId"], git_commit_id) }
|
|
1145
|
+
return nil if matched_logs.empty?
|
|
1146
|
+
|
|
1147
|
+
if !branch.nil?
|
|
1148
|
+
branch_text = branch.to_s
|
|
1149
|
+
branch_matched = matched_logs.find { |item| item["branch"].to_s == branch_text }
|
|
1150
|
+
return branch_matched if branch_matched
|
|
1141
1151
|
end
|
|
1142
1152
|
|
|
1143
|
-
return
|
|
1153
|
+
return matched_logs.first
|
|
1144
1154
|
end
|
|
1145
1155
|
rescue => e
|
|
1146
1156
|
Funlog.instance.warning("查询 commit_log 列表失败: #{e.message}")
|
|
@@ -1149,6 +1159,30 @@ module Pindo
|
|
|
1149
1159
|
nil
|
|
1150
1160
|
end
|
|
1151
1161
|
|
|
1162
|
+
# 从 commit_log 记录中提取发送消息需要的 indexNo。
|
|
1163
|
+
#
|
|
1164
|
+
# commit_log/list 的真实响应里 indexNo 不在根节点,而在 bindVersions 的各平台包里。
|
|
1165
|
+
# 同一 commit 可能绑定多个平台,send_message 实测使用其中一个包的 indexNo;
|
|
1166
|
+
# 取最大值可匹配当前线上请求数据,并稳定指向最近生成的包序号。
|
|
1167
|
+
#
|
|
1168
|
+
# @param commit_log [Hash, nil] commit_log/list 的单条记录
|
|
1169
|
+
# @return [Integer, nil] indexNo
|
|
1170
|
+
def commit_log_message_index_no(commit_log)
|
|
1171
|
+
return nil unless commit_log.is_a?(Hash)
|
|
1172
|
+
|
|
1173
|
+
root_index_no = commit_log["indexNo"]
|
|
1174
|
+
return root_index_no if root_index_no
|
|
1175
|
+
|
|
1176
|
+
bind_versions = commit_log["bindVersions"]
|
|
1177
|
+
return nil unless bind_versions.is_a?(Hash)
|
|
1178
|
+
|
|
1179
|
+
bind_versions.values.map do |version_info|
|
|
1180
|
+
next nil unless version_info.is_a?(Hash)
|
|
1181
|
+
|
|
1182
|
+
version_info["indexNo"]
|
|
1183
|
+
end.compact.max
|
|
1184
|
+
end
|
|
1185
|
+
|
|
1152
1186
|
def get_user_local_wechat_url( )
|
|
1153
1187
|
|
|
1154
1188
|
wechat_msg_url = nil
|
|
@@ -1780,78 +1814,112 @@ module Pindo
|
|
|
1780
1814
|
|
|
1781
1815
|
# 获取特定 commit 已绑定的包 ID
|
|
1782
1816
|
#
|
|
1783
|
-
#
|
|
1784
|
-
#
|
|
1785
|
-
#
|
|
1817
|
+
# 数据源是 commit_log/list 的 bindVersions。
|
|
1818
|
+
#
|
|
1819
|
+
# 不能用 project_package/bind_list:它按 projectId 查、作用域看似更宽,
|
|
1820
|
+
# 但实测(项目 930 条记录)每条的 commitId、branch、workflowId、commitLogs
|
|
1821
|
+
# 全部为 nil——该接口只返回包本身,不携带 commit 绑定关系,
|
|
1822
|
+
# 按 commitId 过滤会恒得空列表,进而让覆盖式写入误删该 commit 的已有绑定。
|
|
1786
1823
|
#
|
|
1787
1824
|
# 绑定接口是覆盖式写入,调用方需要把已绑定的包一起提交,因此必须区分
|
|
1788
1825
|
# 「确认没有绑定过」和「查不出来」——后者返回空数组会导致已有绑定被静默覆盖丢失。
|
|
1789
1826
|
#
|
|
1790
1827
|
# @param commit_id [String] Git commit SHA(必需)
|
|
1791
|
-
# @param
|
|
1828
|
+
# @param workflow_id [Integer, String] 工作流 ID(必需,接口入参)
|
|
1829
|
+
# @param excluded_package_types [Array<String>] 要排除的平台类型(本次新包会替换这些旧绑定)
|
|
1792
1830
|
# @return [Array<String>, nil] 已绑定的包 ID 数组;查询失败或结构异常时返回 nil
|
|
1793
|
-
def get_commit_bound_package_ids(commit_id:,
|
|
1831
|
+
def get_commit_bound_package_ids(commit_id:, workflow_id:, excluded_package_types: [])
|
|
1794
1832
|
if commit_id.nil? || commit_id.empty?
|
|
1795
1833
|
Funlog.instance.fancyinfo_warning("commit_id 为空,无法查询已绑定的包")
|
|
1796
1834
|
return nil
|
|
1797
1835
|
end
|
|
1798
1836
|
|
|
1799
|
-
if
|
|
1800
|
-
Funlog.instance.fancyinfo_warning("
|
|
1837
|
+
if workflow_id.nil? || workflow_id.to_s.empty?
|
|
1838
|
+
Funlog.instance.fancyinfo_warning("workflow_id 为空,无法查询已绑定的包")
|
|
1801
1839
|
return nil
|
|
1802
1840
|
end
|
|
1803
1841
|
|
|
1804
1842
|
begin
|
|
1805
|
-
result = @pgyer_client.
|
|
1843
|
+
result = @pgyer_client.get_commit_log_list(
|
|
1844
|
+
params: {
|
|
1845
|
+
workflowIds: [workflow_id],
|
|
1846
|
+
pageNo: 1,
|
|
1847
|
+
pageSize: 50,
|
|
1848
|
+
onlyCliff: false
|
|
1849
|
+
}
|
|
1850
|
+
)
|
|
1806
1851
|
|
|
1807
1852
|
# 兼容两种响应格式
|
|
1808
1853
|
response_code = result&.dig("code") || result&.dig("meta", "code")
|
|
1809
1854
|
|
|
1810
1855
|
unless result && (response_code == 0 || response_code == 200)
|
|
1811
1856
|
error_msg = result&.dig("msg") || result&.dig("meta", "message") || "未知错误"
|
|
1812
|
-
Funlog.instance.fancyinfo_warning("
|
|
1813
|
-
debug_dump_bind_list_response(result)
|
|
1857
|
+
Funlog.instance.fancyinfo_warning("查询 Commit #{commit_id[0..7]} 的提交记录失败: #{error_msg}")
|
|
1814
1858
|
return nil
|
|
1815
1859
|
end
|
|
1816
1860
|
|
|
1817
|
-
|
|
1861
|
+
details = result&.dig("data", "details")
|
|
1818
1862
|
|
|
1819
|
-
#
|
|
1820
|
-
|
|
1863
|
+
# code=0 且 details=nil 是接口表达「没有这条 commit」的正常响应(实测确认),
|
|
1864
|
+
# 不是畸形响应。此时该 commit 还没进 commit log,不可能有已记录的绑定。
|
|
1865
|
+
# 若误判为 nil,首次绑定(commit log 尚未生成)会被整体阻断。
|
|
1866
|
+
if details.nil?
|
|
1867
|
+
puts "[PINDO_DEBUG] Commit #{commit_id[0..7]} 不在 commit log 中,视为未绑定" if ENV['PINDO_DEBUG']
|
|
1868
|
+
return []
|
|
1869
|
+
end
|
|
1821
1870
|
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
# 先判空会把结构异常的响应误判成「项目下无绑定」,随后覆盖写入清掉已有绑定。
|
|
1825
|
-
# 分组键的语义(commitId / 平台类型)不影响结果:每条记录自带 commitId,按它过滤即可。
|
|
1826
|
-
unless data.is_a?(Hash)
|
|
1827
|
-
Funlog.instance.fancyinfo_warning("包绑定列表结构异常(#{data.class}),无法确认已有绑定")
|
|
1828
|
-
debug_dump_bind_list_response(result)
|
|
1871
|
+
unless details.is_a?(Array)
|
|
1872
|
+
Funlog.instance.fancyinfo_warning("commit_log/list details 结构异常(#{details.class}),无法确认已有绑定")
|
|
1829
1873
|
return nil
|
|
1830
1874
|
end
|
|
1831
1875
|
|
|
1832
|
-
|
|
1833
|
-
|
|
1876
|
+
matched = details.select { |item| item.is_a?(Hash) && same_commit?(item["commitId"], commit_id) }
|
|
1877
|
+
|
|
1878
|
+
# 接口正常返回但没有这条 commit:该 commit 还没进 commit log,
|
|
1879
|
+
# 也就不可能有已记录的绑定
|
|
1880
|
+
if matched.empty?
|
|
1881
|
+
puts "[PINDO_DEBUG] Commit #{commit_id[0..7]} 不在 commit log 中,视为未绑定" if ENV['PINDO_DEBUG']
|
|
1882
|
+
return []
|
|
1883
|
+
end
|
|
1834
1884
|
|
|
1885
|
+
# 同一个 commitId 在 commit log 里可能对应多条记录(push 一条、tag 一条,
|
|
1886
|
+
# 实测 commit_log/list 可见),哪条带 bindVersions 没有契约保证。
|
|
1887
|
+
# 只取第一条匹配会漏读绑定,进而让覆盖式写入删掉已有绑定,
|
|
1888
|
+
# 因此合并所有匹配记录的绑定。
|
|
1889
|
+
excluded_types = excluded_package_types.map { |item| normalize_package_type(item) }.compact
|
|
1835
1890
|
package_ids = []
|
|
1836
|
-
|
|
1837
|
-
unless
|
|
1838
|
-
Funlog.instance.fancyinfo_warning("
|
|
1891
|
+
matched.each do |commit_info|
|
|
1892
|
+
unless commit_info.key?("bindVersions")
|
|
1893
|
+
Funlog.instance.fancyinfo_warning("commit_log/list 缺少 bindVersions 字段,无法确认已有绑定")
|
|
1894
|
+
return nil
|
|
1895
|
+
end
|
|
1896
|
+
|
|
1897
|
+
bind_versions = commit_info["bindVersions"]
|
|
1898
|
+
|
|
1899
|
+
# 该记录没有绑定信息:未绑定的 commit 就是 null,属正常情况
|
|
1900
|
+
next if bind_versions.nil?
|
|
1901
|
+
|
|
1902
|
+
unless bind_versions.is_a?(Hash)
|
|
1903
|
+
Funlog.instance.fancyinfo_warning("bindVersions 结构异常(#{bind_versions.class}),无法确认已有绑定")
|
|
1839
1904
|
return nil
|
|
1840
1905
|
end
|
|
1841
1906
|
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1907
|
+
# bindVersions 形如 { "ipa" => { "projectPackageId" => "..." }, ... },
|
|
1908
|
+
# 每个平台一个包
|
|
1909
|
+
bind_versions.each do |platform, version_info|
|
|
1910
|
+
next if excluded_types.include?(normalize_package_type(platform))
|
|
1911
|
+
next if version_info.nil?
|
|
1912
|
+
|
|
1913
|
+
unless version_info.is_a?(Hash)
|
|
1914
|
+
Funlog.instance.fancyinfo_warning("bindVersions[#{platform}] 结构异常(#{version_info.class}),无法确认已有绑定")
|
|
1845
1915
|
return nil
|
|
1846
1916
|
end
|
|
1847
1917
|
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
# 覆盖写入时等于把那个包的绑定删掉
|
|
1852
|
-
package_id = pkg["id"]
|
|
1918
|
+
# 有平台条目却拿不到包 id:静默跳过会得到残缺列表,
|
|
1919
|
+
# 覆盖写入时等于把那个平台的绑定删掉
|
|
1920
|
+
package_id = version_info["projectPackageId"]
|
|
1853
1921
|
if package_id.nil? || package_id.to_s.strip.empty?
|
|
1854
|
-
Funlog.instance.fancyinfo_warning("Commit #{commit_id[0..7]}
|
|
1922
|
+
Funlog.instance.fancyinfo_warning("Commit #{commit_id[0..7]} 的 #{platform} 绑定缺少 projectPackageId,无法确认已有绑定")
|
|
1855
1923
|
return nil
|
|
1856
1924
|
end
|
|
1857
1925
|
|
|
@@ -1859,7 +1927,7 @@ module Pindo
|
|
|
1859
1927
|
end
|
|
1860
1928
|
end
|
|
1861
1929
|
|
|
1862
|
-
puts "[PINDO_DEBUG] Commit #{commit_id[0..7]} 已绑定 #{package_ids.size}
|
|
1930
|
+
puts "[PINDO_DEBUG] Commit #{commit_id[0..7]} 已绑定 #{package_ids.size} 个包: #{package_ids.inspect}" if ENV['PINDO_DEBUG']
|
|
1863
1931
|
package_ids.uniq
|
|
1864
1932
|
rescue => e
|
|
1865
1933
|
Funlog.instance.fancyinfo_warning("查询 commit 已绑定的包异常: #{e.message}")
|
|
@@ -1868,25 +1936,40 @@ module Pindo
|
|
|
1868
1936
|
end
|
|
1869
1937
|
end
|
|
1870
1938
|
|
|
1871
|
-
#
|
|
1939
|
+
# 归一化包平台类型,用于比较上传包类型和 bindVersions 平台 key。
|
|
1872
1940
|
#
|
|
1873
|
-
#
|
|
1874
|
-
#
|
|
1875
|
-
#
|
|
1876
|
-
#
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
data = result&.dig("data")
|
|
1883
|
-
summary = if data.is_a?(Hash)
|
|
1884
|
-
data.map { |k, v| [k, v.is_a?(Array) ? "#{v.size} 条" : v.class.to_s] }.to_h
|
|
1885
|
-
else
|
|
1886
|
-
data.class.to_s
|
|
1887
|
-
end
|
|
1941
|
+
# 服务端不同接口可能返回 "ipa"、"IPA" 或 "ipa#packageName" 这类变体。
|
|
1942
|
+
# 绑定接口是覆盖式写入,若同类型旧包没被排除,会出现 ipa 新旧包一起提交,
|
|
1943
|
+
# 最终回读仍是旧 ipa,导致校验缺失新包。
|
|
1944
|
+
#
|
|
1945
|
+
# @param package_type [Object] 平台类型
|
|
1946
|
+
# @return [String, nil] 归一化后的平台类型
|
|
1947
|
+
def normalize_package_type(package_type)
|
|
1948
|
+
value = package_type.to_s.strip.downcase
|
|
1949
|
+
return nil if value.empty?
|
|
1888
1950
|
|
|
1889
|
-
|
|
1951
|
+
value.split('#', 2).first
|
|
1952
|
+
end
|
|
1953
|
+
|
|
1954
|
+
# 判断两个 commit SHA 是否指向同一个提交
|
|
1955
|
+
#
|
|
1956
|
+
# 一端是全长 40 位 SHA、另一端是短 SHA(或大小写不同)时,严格 == 会永不命中。
|
|
1957
|
+
# 对覆盖式写入的 bind_commit 来说这不是「查不到」而是「查成空」,
|
|
1958
|
+
# 会把该 commit 上已有的绑定一起删掉,因此按前缀 + 忽略大小写比对。
|
|
1959
|
+
# 要求较短的一方至少 7 字符,避免过短或异常值产生误匹配。
|
|
1960
|
+
#
|
|
1961
|
+
# @param sha_a [String, nil] 待比较的 SHA
|
|
1962
|
+
# @param sha_b [String, nil] 待比较的 SHA
|
|
1963
|
+
# @return [Boolean] 是否同一个提交
|
|
1964
|
+
def same_commit?(sha_a, sha_b)
|
|
1965
|
+
a = sha_a.to_s.strip.downcase
|
|
1966
|
+
b = sha_b.to_s.strip.downcase
|
|
1967
|
+
return false if a.empty? || b.empty?
|
|
1968
|
+
|
|
1969
|
+
shorter, longer = a.length <= b.length ? [a, b] : [b, a]
|
|
1970
|
+
return false if shorter.length < 7
|
|
1971
|
+
|
|
1972
|
+
longer.start_with?(shorter)
|
|
1890
1973
|
end
|
|
1891
1974
|
|
|
1892
1975
|
# 获取工作流中已绑定的包 ID(已废弃,请使用 get_commit_bound_package_ids)
|
|
@@ -2028,8 +2111,7 @@ module Pindo
|
|
|
2028
2111
|
# @param project_id [String] 项目 ID
|
|
2029
2112
|
# @param workflow_id [Integer] 工作流 ID
|
|
2030
2113
|
# @param commit_id [String] Git commit SHA
|
|
2031
|
-
# @param branch [String, nil]
|
|
2032
|
-
# 会让 commit 与分支错误关联,比不传更糟)
|
|
2114
|
+
# @param branch [String, nil] 分支名(可选,空值时按接口真实参数传空字符串)
|
|
2033
2115
|
# @param single [Boolean] 是否单个提交(可选,默认 true)
|
|
2034
2116
|
# @return [Hash] 发送结果
|
|
2035
2117
|
def send_workflow_message(project_id:, workflow_id:, commit_id:, branch: nil, single: true)
|
|
@@ -2049,15 +2131,22 @@ module Pindo
|
|
|
2049
2131
|
end
|
|
2050
2132
|
|
|
2051
2133
|
begin
|
|
2134
|
+
commit_log = find_commit_log_by_git_commit_id(commit_id, workflow_id, branch)
|
|
2135
|
+
commit_log_id = commit_log && commit_log["id"]
|
|
2136
|
+
index_no = commit_log_message_index_no(commit_log)
|
|
2137
|
+
|
|
2138
|
+
body_params = {
|
|
2139
|
+
single: single,
|
|
2140
|
+
ids: commit_log_id ? [commit_log_id] : nil,
|
|
2141
|
+
commitIds: [commit_id],
|
|
2142
|
+
branch: branch.to_s,
|
|
2143
|
+
indexNo: index_no
|
|
2144
|
+
}.compact
|
|
2145
|
+
|
|
2052
2146
|
result = @pgyer_client.send_commit_log_message(
|
|
2053
2147
|
projectId: project_id,
|
|
2054
2148
|
workflowId: workflow_id,
|
|
2055
|
-
params:
|
|
2056
|
-
single: single,
|
|
2057
|
-
# jpsclient 内部归一化为服务端要求的 branches 数组;nil 时不带该字段
|
|
2058
|
-
branch: branch,
|
|
2059
|
-
commitIds: [commit_id]
|
|
2060
|
-
}.compact
|
|
2149
|
+
params: body_params
|
|
2061
2150
|
)
|
|
2062
2151
|
|
|
2063
2152
|
# 兼容两种响应格式
|
|
@@ -26,6 +26,12 @@ module Pindo
|
|
|
26
26
|
'**/src/main/res'
|
|
27
27
|
].freeze
|
|
28
28
|
|
|
29
|
+
# Unity 工程判定即要求该文件存在(BuildHelper#unity_project?),故用精确路径而非 glob,
|
|
30
|
+
# 避免匹配到 Packages 下嵌入工程里的同名副本。
|
|
31
|
+
UNITY_PATTERNS = [
|
|
32
|
+
'ProjectSettings/ProjectSettings.asset'
|
|
33
|
+
].freeze
|
|
34
|
+
|
|
29
35
|
EXCLUDED_PATH_COMPONENTS = %w[
|
|
30
36
|
.git
|
|
31
37
|
.gradle
|
|
@@ -56,9 +62,12 @@ module Pindo
|
|
|
56
62
|
source_paths(project_path, ANDROID_PATTERNS)
|
|
57
63
|
end
|
|
58
64
|
|
|
59
|
-
#
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
# 导出的平台工程落在已忽略的 GoodPlatform 里,不需要提交。
|
|
66
|
+
# 但 ProjectSettings.asset 是 Unity 源码配置,构建期间会被 Unity 写入
|
|
67
|
+
# (版本号、编译宏等),性质与 iOS 的 project.pbxproj / Info.plist 相同,
|
|
68
|
+
# 不提交就会在构建后残留为未提交改动,且 tag 上拿不到构建实际用的配置。
|
|
69
|
+
def unity(project_path)
|
|
70
|
+
source_paths(project_path, UNITY_PATTERNS)
|
|
62
71
|
end
|
|
63
72
|
|
|
64
73
|
private
|
|
@@ -27,9 +27,9 @@ module Pindo
|
|
|
27
27
|
# @option options [String] :git_commit_time Git commit 时间(可选)
|
|
28
28
|
# @option options [String] :git_commit_desc Git commit 描述(可选)
|
|
29
29
|
# @option options [String] :project_dir 项目目录(可选,用于自动获取 commit 信息)
|
|
30
|
-
# @option options [Hash] :app_info_obj JPS
|
|
31
|
-
#
|
|
32
|
-
#
|
|
30
|
+
# @option options [Hash] :app_info_obj JPS 应用信息对象(可选,继承自基类,本任务不使用)
|
|
31
|
+
# @option options [Hash] :workflow_info 工作流信息(必需,用于取 workflow_id;
|
|
32
|
+
# 回读绑定走 commit_log/preview,该接口以 workflowId 为入参)
|
|
33
33
|
# @option options [String] :project_name 项目名称(可选,继承自基类)
|
|
34
34
|
def initialize(app_version_list = nil, options = {})
|
|
35
35
|
# 兼容性处理:如果传入的是单个 Hash,转为数组
|
|
@@ -118,6 +118,7 @@ module Pindo
|
|
|
118
118
|
if project_package_ids.empty?
|
|
119
119
|
raise "app_version_list 中的包都缺少 id 字段"
|
|
120
120
|
end
|
|
121
|
+
package_types = @app_version_list.map { |pkg| package_type_from(pkg) }.compact.uniq
|
|
121
122
|
|
|
122
123
|
# 4. 打印绑定信息
|
|
123
124
|
puts ""
|
|
@@ -125,7 +126,7 @@ module Pindo
|
|
|
125
126
|
puts " Git Commit: #{@git_commit_id[0..7]}"
|
|
126
127
|
puts " 包数量: #{project_package_ids.size} 个"
|
|
127
128
|
@app_version_list.each do |pkg|
|
|
128
|
-
package_type = pkg
|
|
129
|
+
package_type = raw_package_type_from(pkg) || 'unknown'
|
|
129
130
|
puts " [#{package_type}] ID: #{pkg['id']}, Version: #{pkg['projectVersion']}, Build: #{pkg['build']}"
|
|
130
131
|
end
|
|
131
132
|
if @git_commit_desc
|
|
@@ -142,16 +143,19 @@ module Pindo
|
|
|
142
143
|
raise "无法登录 JPS,请检查配置"
|
|
143
144
|
end
|
|
144
145
|
|
|
145
|
-
# 6.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
# 6. 获取工作流 ID(commit_log/preview 的入参;绑定本身按 commitId 全局记录,
|
|
147
|
+
# 同项目下任一 workflowId 查到的 bindVersions 都相同)
|
|
148
|
+
workflow_id = @workflow_info&.dig(:workflow_id) || @workflow_info&.dig('workflow_id') ||
|
|
149
|
+
@workflow_info&.dig(:id) || @workflow_info&.dig('id')
|
|
150
|
+
unless workflow_id
|
|
151
|
+
raise "缺少 workflow_info,无法获取 workflow_id"
|
|
149
152
|
end
|
|
150
153
|
|
|
151
154
|
# 7. 获取当前 commit 已绑定的包 ID
|
|
152
155
|
existing_bound_ids = pgyer_helper.get_commit_bound_package_ids(
|
|
153
156
|
commit_id: @git_commit_id,
|
|
154
|
-
|
|
157
|
+
workflow_id: workflow_id,
|
|
158
|
+
excluded_package_types: package_types
|
|
155
159
|
)
|
|
156
160
|
|
|
157
161
|
# 查询失败(nil)时中止:绑定接口是覆盖式写入,带着不完整的列表提交
|
|
@@ -164,8 +168,8 @@ module Pindo
|
|
|
164
168
|
puts " 📋 当前 Commit 已绑定的包: #{existing_bound_ids.size} 个"
|
|
165
169
|
end
|
|
166
170
|
|
|
167
|
-
# 8.
|
|
168
|
-
merged_package_ids = (
|
|
171
|
+
# 8. 合并新上传的包 ID 和其它平台已绑定的 ID(同平台旧包已在查询时排除)
|
|
172
|
+
merged_package_ids = (project_package_ids + existing_bound_ids).uniq
|
|
169
173
|
|
|
170
174
|
puts " 📦 合并后的包 ID 数量: #{merged_package_ids.size} 个"
|
|
171
175
|
if merged_package_ids.size > project_package_ids.size
|
|
@@ -196,7 +200,7 @@ module Pindo
|
|
|
196
200
|
# 根治需要服务端支持,二选一即可:
|
|
197
201
|
# 1) bind_commit 增加 append 语义(只追加不覆盖)
|
|
198
202
|
# 2) 返回并校验 revision,做乐观并发控制
|
|
199
|
-
verify_bound_packages(pgyer_helper,
|
|
203
|
+
verify_bound_packages(pgyer_helper, workflow_id, merged_package_ids)
|
|
200
204
|
|
|
201
205
|
puts ""
|
|
202
206
|
|
|
@@ -219,18 +223,40 @@ module Pindo
|
|
|
219
223
|
|
|
220
224
|
private
|
|
221
225
|
|
|
226
|
+
def package_type_from(pkg)
|
|
227
|
+
normalize_package_type(raw_package_type_from(pkg))
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def raw_package_type_from(pkg)
|
|
231
|
+
return nil unless pkg.respond_to?(:[])
|
|
232
|
+
|
|
233
|
+
pkg['nativePackageType'] || pkg[:nativePackageType] ||
|
|
234
|
+
pkg['originalType'] || pkg[:originalType] ||
|
|
235
|
+
pkg['packageType'] || pkg[:packageType] ||
|
|
236
|
+
pkg['native_package_type'] || pkg[:native_package_type] ||
|
|
237
|
+
pkg['original_type'] || pkg[:original_type] ||
|
|
238
|
+
pkg['type'] || pkg[:type]
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def normalize_package_type(package_type)
|
|
242
|
+
value = package_type.to_s.strip.downcase
|
|
243
|
+
return nil if value.empty?
|
|
244
|
+
|
|
245
|
+
value.split('#', 2).first
|
|
246
|
+
end
|
|
247
|
+
|
|
222
248
|
# 写后回读校验:确认期望绑定的包都在服务端的绑定列表里
|
|
223
249
|
#
|
|
224
250
|
# 查询失败时只告警不失败——包已经写进去了,回读失败不代表绑定失败。
|
|
225
251
|
# 只有确认「期望的包没在列表里」才判定为被并发覆盖,抛异常交给任务重试。
|
|
226
252
|
#
|
|
227
253
|
# @param pgyer_helper [PgyerHelper] 已登录的 helper
|
|
228
|
-
# @param
|
|
254
|
+
# @param workflow_id [Integer, String] 工作流 ID
|
|
229
255
|
# @param expected_ids [Array<String>] 本次写入的包 ID 列表
|
|
230
|
-
def verify_bound_packages(pgyer_helper,
|
|
256
|
+
def verify_bound_packages(pgyer_helper, workflow_id, expected_ids)
|
|
231
257
|
actual_ids = pgyer_helper.get_commit_bound_package_ids(
|
|
232
258
|
commit_id: @git_commit_id,
|
|
233
|
-
|
|
259
|
+
workflow_id: workflow_id
|
|
234
260
|
)
|
|
235
261
|
|
|
236
262
|
if actual_ids.nil?
|
|
@@ -152,13 +152,17 @@ module Pindo
|
|
|
152
152
|
|
|
153
153
|
# 计算上传耗时
|
|
154
154
|
upload_duration = Time.now - upload_start_time
|
|
155
|
-
upload_speed = file_size_mb / upload_duration
|
|
156
|
-
puts "✅ 文件上传完成! 耗时: #{upload_duration.round(2)} 秒, 平均速度: #{upload_speed.round(2)} MB/s"
|
|
157
155
|
|
|
156
|
+
# 判空必须放在打印「上传完成」之前:upload_file 失败返回 nil,
|
|
157
|
+
# 先打印会输出一句假的完成提示,外加一个用完整文件大小除以失败耗时算出的假速度
|
|
158
158
|
if file_url.nil?
|
|
159
|
+
puts "❌ 文件上传失败! 耗时: #{upload_duration.round(2)} 秒"
|
|
159
160
|
raise Informative, "文件上传失败"
|
|
160
161
|
end
|
|
161
162
|
|
|
163
|
+
upload_speed = file_size_mb / upload_duration
|
|
164
|
+
puts "✅ 文件上传完成! 耗时: #{upload_duration.round(2)} 秒, 平均速度: #{upload_speed.round(2)} MB/s"
|
|
165
|
+
|
|
162
166
|
puts "✅ 文件上传成功"
|
|
163
167
|
puts
|
|
164
168
|
|
data/lib/pindo/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pindo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.20.
|
|
4
|
+
version: 5.20.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- wade
|
|
@@ -112,7 +112,7 @@ dependencies:
|
|
|
112
112
|
version: '2.7'
|
|
113
113
|
- - ">="
|
|
114
114
|
- !ruby/object:Gem::Version
|
|
115
|
-
version: 2.7.
|
|
115
|
+
version: 2.7.3
|
|
116
116
|
type: :runtime
|
|
117
117
|
prerelease: false
|
|
118
118
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -122,7 +122,7 @@ dependencies:
|
|
|
122
122
|
version: '2.7'
|
|
123
123
|
- - ">="
|
|
124
124
|
- !ruby/object:Gem::Version
|
|
125
|
-
version: 2.7.
|
|
125
|
+
version: 2.7.3
|
|
126
126
|
- !ruby/object:Gem::Dependency
|
|
127
127
|
name: rqrcode
|
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -531,7 +531,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
531
531
|
- !ruby/object:Gem::Version
|
|
532
532
|
version: 3.0.0
|
|
533
533
|
requirements: []
|
|
534
|
-
rubygems_version: 4.0.
|
|
534
|
+
rubygems_version: 4.0.10
|
|
535
535
|
specification_version: 4
|
|
536
536
|
summary: easy work
|
|
537
537
|
test_files: []
|