Repository navigation
Provide all metadata fields in scripted pr view #1532
Copy link
Copy link
Labels
coreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIa request to improve CLIneeds-designAn engineering task needs design to proceedAn engineering task needs design to proceed
Description
Describe the feature or problem you’d like to solve
I am trying to automate doing something with the PR just created from the current branch. gh pr view will print out the PR info including the URL, which would be fine, except that if your redirect stdout it drops this information. (I understand having a command behave differently in interactive vs scripted contexts, but this seems like a pretty surprising behavior).
Proposed solution
All information in the interactive view should also be present in the scripted view. In particular gh pr view should include the PR number and URL (and/or include the owner and repo name as separate fields).
How will it benefit CLI and its users?
This enables gh to be used with other automation that operates on PRs.
Additional context
Current behavior
gcmn@ws 2020-08-14 10:56 ~/git/iree$ gh pr view
Merge main -> google
Open • GMNGeoffrey wants to merge 14 commits into google from main-to-google
Labels: cla: yes
• e15008ca Standardize E2E module names. (#2872)
• e5d0f61e Add support for mhlo.log_plus_one on all the backends. (2873)
• 177925c4 Mark unanalyzable XLA target as manual (#2881)
• 8204a7a8 Merge google -> main #2877
• 45d5f5a1 Avoid confusing error message in TF tests (#2879)
• 064dd2b7 Merge pull request #2742 from google/benvanik-vm64-flags
• c2e59d2e Workaround for issue in #2878.
• 99ed353d Reworking type conversion to support VM target options.
• a8ef9dc3 Supporting new VM TargetOptions type conversion in std->vm.
• 0a473431 Plumbing VM TargetOptions through conversion passes.
• 87c96f26 Adding IREE::VM::TargetOptions and --iree-vm-target-* flags.
• 2ff8b399 Removing unused TypeConversionUtils.
• 3546d64c Merge google -> main (#2876)
• d13546b2 Remove uses of kind on derived mlir Attribute and Type classes
(#2861)
View this pull request on GitHub: https://github.com/google/iree/pull/2887
gcmn@ws 2020-08-14 10:56 ~/git/iree$ gh pr view > /tmp/pr.txt && cat /tmp/pr.txt
title: Merge main -> google
state: OPEN
author: GMNGeoffrey
labels: cla: yes
assignees:
reviewers:
projects:
milestone:
--
* e15008ca Standardize E2E module names. (#2872)
* e5d0f61e Add support for mhlo.log_plus_one on all the backends. (2873)
* 177925c4 Mark unanalyzable XLA target as manual (#2881)
* 8204a7a8 Merge google -> main #2877
* 45d5f5a1 Avoid confusing error message in TF tests (#2879)
* 064dd2b7 Merge pull request #2742 from google/benvanik-vm64-flags
* c2e59d2e Workaround for issue in #2878.
* 99ed353d Reworking type conversion to support VM target options.
* a8ef9dc3 Supporting new VM TargetOptions type conversion in std->vm.
* 0a473431 Plumbing VM TargetOptions through conversion passes.
* 87c96f26 Adding IREE::VM::TargetOptions and --iree-vm-target-* flags.
* 2ff8b399 Removing unused TypeConversionUtils.
* 3546d64c Merge google -> main (#2876)
* d13546b2 Remove uses of kind on derived mlir Attribute and Type classes (#2861)```
Proposed behavior
gcmn@ws 2020-08-14 10:56 ~/git/iree$ gh pr view
Merge main -> google
Open • GMNGeoffrey wants to merge 14 commits into google from main-to-google
Labels: cla: yes
• e15008ca Standardize E2E module names. (#2872)
• e5d0f61e Add support for mhlo.log_plus_one on all the backends. (2873)
• 177925c4 Mark unanalyzable XLA target as manual (#2881)
• 8204a7a8 Merge google -> main #2877
• 45d5f5a1 Avoid confusing error message in TF tests (#2879)
• 064dd2b7 Merge pull request #2742 from google/benvanik-vm64-flags
• c2e59d2e Workaround for issue in #2878.
• 99ed353d Reworking type conversion to support VM target options.
• a8ef9dc3 Supporting new VM TargetOptions type conversion in std->vm.
• 0a473431 Plumbing VM TargetOptions through conversion passes.
• 87c96f26 Adding IREE::VM::TargetOptions and --iree-vm-target-* flags.
• 2ff8b399 Removing unused TypeConversionUtils.
• 3546d64c Merge google -> main (#2876)
• d13546b2 Remove uses of kind on derived mlir Attribute and Type classes
(#2861)
View this pull request on GitHub: https://github.com/google/iree/pull/2887
gcmn@ws 2020-08-14 10:56 ~/git/iree$ gh pr view > /tmp/pr.txt && cat /tmp/pr.txt
title: Merge main -> google
state: OPEN
author: GMNGeoffrey
labels: cla: yes
number: 2887
commit_count: 14
url: https://github.com/google/iree/pull/2887
base_repo_owner: google
base_repo: iree
base_branch: google
pr_repo_owner: GMNGeoffrey
pr_repo: iree
pr_branch: main-to-google
assignees:
reviewers:
projects:
milestone:
--
* e15008ca Standardize E2E module names. (#2872)
* e5d0f61e Add support for mhlo.log_plus_one on all the backends. (2873)
* 177925c4 Mark unanalyzable XLA target as manual (#2881)
* 8204a7a8 Merge google -> main #2877
* 45d5f5a1 Avoid confusing error message in TF tests (#2879)
* 064dd2b7 Merge pull request #2742 from google/benvanik-vm64-flags
* c2e59d2e Workaround for issue in #2878.
* 99ed353d Reworking type conversion to support VM target options.
* a8ef9dc3 Supporting new VM TargetOptions type conversion in std->vm.
* 0a473431 Plumbing VM TargetOptions through conversion passes.
* 87c96f26 Adding IREE::VM::TargetOptions and --iree-vm-target-* flags.
* 2ff8b399 Removing unused TypeConversionUtils.
* 3546d64c Merge google -> main (#2876)
* d13546b2 Remove uses of kind on derived mlir Attribute and Type classes (#2861)```
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
coreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIa request to improve CLIneeds-designAn engineering task needs design to proceedAn engineering task needs design to proceed
Activity
mislav commentedon Aug 17, 2020
Thanks for the feature request!
Do you think a good solution would be to add extra fields for both PR number and URL in the scripted output?
Ref. #1373
GMNGeoffrey commentedon Aug 17, 2020
I included a collapsed suggestion for what I think this could look like. You could include all the informative parts of the URL as separate fields (owner and repo separately), which I think is nicer for scripting than having to parse the URL. The URL is probably useful enough on its own that it might be also nice to have it as denormalized output. I also noticed there are a few other pieces of information only visible in the interactive output: the count of commits in the PR and the branch the PR is from. I don't currently have a use case for those, but I think that any information in the interactive view should also be accessible in the scripted output.
mislav commentedon Aug 17, 2020
Absolutely; thank you for the suggestions!
GMNGeoffrey commentedon Aug 26, 2020
I think the linked commit doesn't quite close this issue because there's still info that is only available in the non-TTY output:
GMNGeoffrey commentedon Aug 26, 2020
But thanks for adding the PR number! That solves my use case :-)
GMNGeoffrey commentedon Sep 16, 2020
@mislav Ping on the above comment, since I don't think this issue is actually fully fixed.
mislav commentedon Sep 17, 2020
@GMNGeoffrey Sorry about that! Reopening
I'm thinking that, instead of listing every possible attribute of a PR in a line-based format, we could consider allowing you to specify exactly which fields you need and output just those in a format of your choosing (JSON, YAML, etc.). #1089
[-]`gh pr view` should provide all information when scripted (e.g. PR number)[/-][+]Provide all metadata fields in scripted `pr view`[/+]GMNGeoffrey commentedon Sep 17, 2020
No worries. I agree some sort of structured output would be nice
mislav commentedon Apr 14, 2021
@GMNGeoffrey Please try out the
gh pr view --jsonthat will be new in today's release and let us know if that covers your needs!Example use:
An additional
--jqexpression might be supplied to turn the JSON into something immediately usable in a shell script.