Skip to content

refactor: use gh api --jq instead of jq - #14963

Merged
sylvestre merged 2 commits into
uutils:mainfrom
xtqqczze:GH9581
Sep 29, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
xtqqczze:GH9581

Conversation

@xtqqczze

@xtqqczze xtqqczze commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Simplify GHA-delete-GNU-workflow-logs.sh by using the --jq option provided by gh api instead of invoking the external jq utility.

This removes the separate jq dependency and the associated availability check.

Reverts #9581.

cc: @oech3

…d support jaq for the case it is not installed as jq (uutils#9581)"

This reverts commit 3528d10.
@oech3

oech3 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

I did not test it. But fine for me.

@xtqqczze

xtqqczze commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

I verified that:

gh api "repos/uutils/coreutils/actions/runs" --jq ".workflow_runs[] | (.id)"

has same output as:

gh api "repos/uutils/coreutils/actions/runs" | jq -r ".workflow_runs[] | (.id)"

Comment thread util/GHA-delete-GNU-workflow-logs.sh
Comment thread util/GHA-delete-GNU-workflow-logs.sh Outdated
"${GH}" api "repos/${USER_NAME}/${REPO_NAME}/actions/runs" |
"${JQ}" -r ".workflow_runs[] | select(.name == \"${WORK_NAME}\") | (.id)" |
xargs -n1 sh -c "for arg do { echo ${GH} api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; if [ -z \"${dry_run}\" ]; then ${GH} api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; fi ; } ; done ;" _
gh api "repos/${USER_NAME}/${REPO_NAME}/actions/runs" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add --paginate here while at it? it works fine with --jq and the comment above already talks about it

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not keen on refactoring this code, since I have no method to test.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the commented out code is the same thing as below, but without --paginate, so apparently --paginate was consciously removed at some point.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented-out code using --paginate has been there since the file was originally added by @rivy: c74bc2e

@sylvestre
sylvestre merged commit 2f0bd06 into uutils:main Sep 29, 2026
89 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

@xtqqczze
xtqqczze deleted the GH9581 branch September 30, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants