Skip to content

When using GH_TOKEN to authenticate, --web open forms bad URLs  #4518

@georgegillams

Description

@georgegillams

Describe the bug

When using a GH_TOKEN environment variable to authenticate, gh pr create --web opens a badly formatted URL.
gh version 2.0.0 (2021-08-23)
macOS - M1 processor

Steps to reproduce the behavior

With GH_TOKEN:

  1. export GH_TOKEN
  2. Push changes to a new branch
  3. gh pr create --web opens a URL in the wrong format - https://github.com///compare/...ORG_NAME%3ABRANCH-NAME?body=&expand=1

With HTTP/SSH:

  1. Without GH_TOKEN configured, sign in using gh auth login
  2. Push changes to a new branch
  3. gh pr create --web opens a URL in the correct format - https://github.com/ORG_NAME/REPO_NAME/compare/main...BRANCH_NAME?body=&expand=1

Expected vs actual behavior

I would expect the behaviour to be the same regardless of how the user is authenticated

Logs

When authenticated with GH_TOKEN:

> gh pr create --web
Opening github.com///compare/...ORG_NAME:BRANCH_NAME in your browser.

When authenticated with HTTP/SSH:

> gh pr create --web
Opening github.com/ORG_NAME/REPO_NAME/compare/main...BRANCH_NAME in your browser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority-3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions