Skip to content

Excuting "gh browse gh browse -c -R owner/repo" inside another repo workspace uses the last commit of the workspace repo #4715

Closed

Description

@crguezl

Describe the bug

When executing gh browse gh browse -c -R owner/repo inside the work tree of another repo uses the last commit of the workspace repo:

Example

➜  gh-learning git:(master) ✗ gh browse -c -R ULL-MFP-AET-2122/static-generator-angel-ramallobenitez-alu0100312898 -n
https://github.com/ULL-MFP-AET-2122/static-generator-angel-ramallobenitez-alu0100312898/tree/a27a1db2a3a10fae176024bf13444f27af44c7d0/gh-learning

That is the last commit of the current repo:

➜  gh-learning git:(master) ✗ git log -n 1
commit a27a1db2a3a10fae176024bf13444f27af44c7d0 (HEAD -> master)
Author: Casiano Rodriguez-Leon <[email protected]>
Date:   Fri May 14 11:08:29 2021 +0100

    Auto-commit

Of course if we omit the -n option we get the 404:

Captura de pantalla 2021-11-12 a las 8 38 28

Expected behavior

It has to use the last commit of the repo specified in the command line argument -R owner/repo

Activity

  1. added
    priority-3Affects a small number of users or is largely cosmetic
    on Nov 23, 2021
  2. mislav commented on Nov 23, 2021

    @mislav
    Contributor

    Thank you for reporting! Good catch; and I agree with your assessment. Since you've specified a repository using the -R flag, we should't pay attention to the local git repo anymore, but we erroneously still do.

  3. despreston commented on Nov 24, 2021

    @despreston
    Contributor

    Is it possible to run a git command against a remote repo? I know you can specify -C with some commands to point to a different local directory, but that doesn't let you run against a remote repo afaik. Would be nice to fix this without having to use the GH api to get the last commit SHA.

  4. mislav commented on Nov 25, 2021

    @mislav
    Contributor

    @despreston No, to solve this we would have to take one of the following approaches:

    1. Error out if -c was used with --repo; or
    2. Use the GitHub API to determine the commit SHA so we can construct the URL.
  5. added a commit that references this issue on Dec 3, 2021
    1dcc901
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

    bugSomething isn't workinghelp wantedContributions welcomepriority-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