Skip to content

gh browse subdirectory path problem with repo flag #7674

@LangLangBart

Description

@LangLangBart
gh --version
# gh version 2.31.0 (2023-06-20)

Describe the bug

  • run gh browse --repo <OWNER_NAME> <FILE_PATH> from a git subdirectory, it messes up the URL

example

# move into a given 'git'  repository, for example "cli"
cd cli
# run the gh browse command to open the "README" of "Zotero"
# it works correctly
gh browse --repo zotero/zotero README.md --no-browser
# https://github.com/zotero/zotero/tree/main/README.md

# move one directory level down in your 'git' repo
cd utils/
# run the same command again and notice 'utils' is wrongly placed within the link
gh browse --repo zotero/zotero README.md --no-browser
# https://github.com/zotero/zotero/tree/main/utils/README.md

bisect

# 70c78f2aa896f2c6baf9a045c087f1042fd4b62d is the first bad commit
# commit 70c78f2aa896f2c6baf9a045c087f1042fd4b62d
# Author: nate smith <vilmibm@github.com>
# Date:   Thu Oct 14 17:07:51 2021 -0500

#     some fixes, streamlining

#  pkg/cmd/browse/browse.go      | 56 ++++++++++-------------------
#  pkg/cmd/browse/browse_test.go | 82 +++++++++++++------------------------------
#  2 files changed, 43 insertions(+), 95 deletions(-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-browserelating to the gh browse commandhelp wantedContributions welcomep3Affects 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