Skip to content

Provide all metadata fields in scripted pr view #1532

Description

@GMNGeoffrey

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)```

Activity

  1. mislav commented on Aug 17, 2020

    @mislav
    Contributor

    Thanks for the feature request!

    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).

    Do you think a good solution would be to add extra fields for both PR number and URL in the scripted output?

    number: 1234
    url: https://github.com/OWNER/REPO/pull/1234
    

    Ref. #1373

  2. GMNGeoffrey commented on Aug 17, 2020

    @GMNGeoffrey
    Author

    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.

  3. mislav commented on Aug 17, 2020

    @mislav
    Contributor

    Absolutely; thank you for the suggestions!

  4. GMNGeoffrey commented on Aug 26, 2020

    @GMNGeoffrey
    Author

    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:

    commit_count: 14
    base_repo_owner: google
    base_repo: iree
    base_branch: google
    pr_repo_owner: GMNGeoffrey
    pr_repo: iree
    pr_branch: main-to-google
    
  5. GMNGeoffrey commented on Aug 26, 2020

    @GMNGeoffrey
    Author

    But thanks for adding the PR number! That solves my use case :-)

  6. GMNGeoffrey commented on Sep 16, 2020

    @GMNGeoffrey
    Author

    @mislav Ping on the above comment, since I don't think this issue is actually fully fixed.

  7. mislav commented on Sep 17, 2020

    @mislav
    Contributor

    @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

  8. reopened this on Sep 17, 2020
  9. changed the title [-]`gh pr view` should provide all information when scripted (e.g. PR number)[/-] [+]Provide all metadata fields in scripted `pr view`[/+] on Sep 17, 2020
  10. GMNGeoffrey commented on Sep 17, 2020

    @GMNGeoffrey
    Author

    No worries. I agree some sort of structured output would be nice

  11. added
    coreThis issue is not accepting PRs from outside contributors
    needs-designAn engineering task needs design to proceed
    on Oct 7, 2020
  12. mislav commented on Apr 14, 2021

    @mislav
    Contributor

    @GMNGeoffrey Please try out the gh pr view --json that will be new in today's release and let us know if that covers your needs!

    Example use:

    $ gh pr view [PRNUMBER] --json headRefName,url,headRepository
    

    An additional --jq expression might be supplied to turn the JSON into something immediately usable in a shell script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIneeds-designAn engineering task needs design to proceed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions