Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add json output mode to reviews #46

Merged
merged 5 commits into from
Feb 23, 2024
Merged

Conversation

quotidian-ennui
Copy link
Owner

@quotidian-ennui quotidian-ennui commented Feb 23, 2024

Motivation

Pipe chaining because we want oneliner coolness:

gh my reviews | grep "bump pre-commit" | awk '{ print $9 }' \
  | xargs -L 1 gh pr view --comments | grep "Terraform Plan"

The awk { print $9 } could be be brittle since you are relying on dependabot's commit message to only have a certain number of spaces (deps: bump x from 1.2.3 to 2.3.4 == 7 fields) along with the initial field being PR number at the start.

Making a JSON variant means that we could do this which doesn't change the semantics but enables us to be less brittle.

gh my reviews | grep "bump pre-commit" | jq -c -r '.url' \
| xargs -L 1 gh pr view --comments | grep "Terraform Plan"

Changes

  • Introduce a -j flag to reviews (which could be added to other subcommands)
  • -j forces --jq execution rather than --template (they are mutually exclusive)

Test

bsh ❯ ./gh-my reviews -j
{"login":"qe-repo-updater","number":75,"title":"chore(deps): Bump orhun/git-cliff version to v2.0.4","url":"https://github.com/quotidian-ennui/ubuntu-dpm/pull/75"}
bsh ❯ ./gh-my reviews
Num  Title                                                Who              URL                                                    When
#75  chore(deps): Bump orhun/git-cliff version to v2.0.4  qe-repo-updater  https://github.com/quotidian-ennui/ubuntu-dpm/pull/75  12 hours ago

@quotidian-ennui quotidian-ennui marked this pull request as ready for review February 23, 2024 15:57
@quotidian-ennui quotidian-ennui merged commit 88746c8 into main Feb 23, 2024
4 checks passed
@quotidian-ennui quotidian-ennui deleted the feat/json-output branch February 23, 2024 17:08
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.

2 participants