Skip to content

GitKind extensions are not treated as pinned correctly #10228

Description

@williammartin

Describe the bug

➜ gh ext install --pin 81a4ce86e027f31d306883c25a71b5d05b007e2e andyfeller/gh-sonar
⣷Cloning into '/Users/williammartin/.local/share/gh/extensions/gh-sonar'...
⢿remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (8/8), done.
⡿remote: Total 10 (delta 1), reused 7 (delta 1), pack-reused 0 (from 0)
Receiving objects: 100% (10/10), 6.64 KiB | 6.64 MiB/s, done.
Resolving deltas: 100% (1/1), done.
✓ Installed extension andyfeller/gh-sonar
✓ Pinned extension at 81a4ce86e027f31d306883c25a71b5d05b007e2e

This looks like it is pinned correctly. However...running gh ext list doesn't show it in blue (indicating pinned), and...

➜  gh ext upgrade gh-sonar --dry-run
[sonar]: would have upgraded from 81a4ce86 to 9977d8e5
✓ Successfully checked extension upgrades

Whereas a pinned extension would say:

➜  gh ext upgrade gh-sarif --dry-run
[sarif]: pinned extensions can not be upgraded
✓ Successfully checked extension upgrades

Separately, upgrading doesn't work at all, but that's another issue (to be created)

Acceptance Criteria

Given I installed a pinned, script-based GitHub CLI extension using gh ext install --pin SHA
When I execute gh ext upgrade <EXT> --dry-run
Then gh states pinned extensions can not be upgraded


Given I installed a pinned, script-based GitHub CLI extension using gh ext install --pin SHA
When I execute gh ext list
Then I see the extension sha is coloured cyan

In the following example, the version for gh-eco is colored cyan because it is a pinned extension:

Screenshot of terminal displaying GitHub CLI extensions with gh-eco version being cyan

Activity

  1. andyfeller commented on Jan 13, 2025

    @andyfeller
    Contributor

    Thanks for opening this issue, @williammartin! ❤

    If I'm following along, then I assume the acceptance criteria for this bug report is:

    Given I installed a pinned, script-based GitHub CLI extension using gh ext install --pin SHA
    When I execute gh ext upgrade <EXT> --dry-run
    Then gh states pinned extensions can not be upgraded

    Separately, I think the message provided by gh ext upgrade isn't actionable enough and wonder how we incorporate an additional message to help the user:

    ➜  gh ext upgrade gh-sarif --dry-run
    [sarif]: pinned extensions can not be upgraded
    ✓ Successfully checked extension upgrades
    
    To upgrade pinned extensions, run `gh ext install <ext> --force`.
  2. williammartin commented on Jan 13, 2025

    @williammartin
    MemberAuthor

    This occurs because checking whether a GitKind extension is pinned tries to check the existence of a file in the git repo, but the path concatenation is incorrect, because it concatenates the executable path (rather than the dir containing the executable).

    pinPath := filepath.Join(e.Path(), fmt.Sprintf(".pin-%s", e.CurrentVersion()))

    This was introduced in #7493 and has been broken since. The previous commit correctly represents the pinned ext in ext list.

  3. williammartin commented on Jan 13, 2025

    @williammartin
    MemberAuthor

    I would also expect:

    Given I installed a pinned, script-based GitHub CLI extension using gh ext install --pin SHA
    When I execute gh ext list
    Then I see the extension sha is coloured blue (or whatever my terminal colouring is set to for that)

  4. added
    priority-3Affects a small number of users or is largely cosmetic
    and removed
    more-info-neededMore info needed from user/contributor
    on Jan 13, 2025
  5. esvarez commented on Jan 14, 2025

    @esvarez

    ~~Hello, I want to start contributing to open-source projects. This seems to be a good point to begin with. Where can I find the guide to contribute to the project? ~~

    I already saw it in the readme

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 workinggh-extensionrelating to the gh extension commandhelp 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