Skip to content

2.66.0 regression: gh pr subcommands don't work anymore if called outside of Git repository #10352

Closed

Description

@rd-yan-farba

Describe the bug

Hi dear team!

After upgrading to GitHub CLI 2.66.0 we noticed that running gh pr <cmd> <url> fails with the message:

The error message was the following:

could not determine current branch: failed to run git: fatal: not a git repository (or any of the parent directories): .git

It happens when we run the commands outside of git repository.

We use the gh pr command in composite action, providing a valid token and using ${{ github.event.pull_request.html_url }} as PR URL. Previous versions worked without checking out the repository.

Affected version

2.66.0

Steps to reproduce the behavior

  1. Upgrade to GitHub CLI 2.66.0
  2. Run any gh pr subcommand (e.g. gh pr view <url>) outside of git repository
  3. See error:
could not determine current branch: failed to run git: fatal: not a git repository (or any of the parent directories): .git

Expected vs actual behavior

Earlier version of gh pr worked in our workflows without checking out the repository.

We would expect it to work, since we use gh pr with explicit PR URL, in which base and head branches are set.

Activity

  1. andyfeller commented on Jan 31, 2025

    @andyfeller
    Contributor

    Thank you for raising this issue, @rd-yan-farba! 🙇 I'm going to begin digging into this and working with the other maintainers regarding the changes from #9208.

  2. pinned this issue on Jan 31, 2025
  3. added
    coreThis issue is not accepting PRs from outside contributors
    on Jan 31, 2025
  4. andyfeller commented on Jan 31, 2025

    @andyfeller
    Contributor

    @rd-yan-farba : working with @jtmcg and @BagToad, we think we've gotten to the root of this issue and have been refactoring some code and tests to ensure this is properly addressed. we are hoping to cut a hotfix today and hope that we could follow up with you when its available for confirmation this is fixed.

  5. self-assigned this
    on Feb 1, 2025
  6. rd-yan-farba commented on Feb 3, 2025

    @rd-yan-farba
    Author

    Thanks for the quick response and the hotfix!🚀 I can confirm the issue was resolved

  7. added a commit that references this issue on Feb 4, 2025
  8. deleted a comment from char23-web on Feb 6, 2025
  9. blackmann92 commented on Feb 8, 2025

    @blackmann92

    Hvala

  10. unpinned this issue on Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingcoreThis issue is not accepting PRs from outside contributorsneeds-triageneeds to be reviewedpriority-1Affects a large population and inhibits work

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions