Skip to content

Commit cf5a01e

Browse files
CopilotSoulter
andcommitted
Optimize logo validation with single jq call
Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
1 parent a8af48e commit cf5a01e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • scripts/transform_plugin_data/get_github_api_info_for_repositories

scripts/transform_plugin_data/get_github_api_info_for_repositories/run.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ jq -r 'to_entries[] | .value.repo // empty' original_plugins.json | while read -
239239
"https://api.github.com/repos/$owner/$repo/contents/logo.png" 2>/dev/null || echo "{}")
240240

241241
# 检查logo.png是否存在(验证响应包含name字段且不是错误消息)
242-
if echo "$logo_response" | jq -e '.name' > /dev/null 2>&1 && \
243-
! echo "$logo_response" | jq -e '.message' > /dev/null 2>&1; then
242+
# 使用单个jq调用进行验证以提高性能
243+
logo_valid=$(echo "$logo_response" | jq -r 'if .name and (.message | not) then "true" else "false" end' 2>/dev/null || echo "false")
244+
if [ "$logo_valid" = "true" ]; then
244245
# 获取默认分支
245246
default_branch=$(echo "$api_response" | jq -r '.default_branch // "main"')
246247
logo="https://raw.githubusercontent.com/$owner/$repo/$default_branch/logo.png"

0 commit comments

Comments
 (0)