Skip to content

Updating of a repo variable returns a Created message instead of Updated message  #8712

Description

@Naedish

Describe the bug

When updating an existing repo variable the return message is Created instead of Updated. This behaviour isn't observed for Environment or Organisation variables, only repo variables.

gh --version
gh version 2.44.1 (2024-02-16)
https://github.com/cli/cli/releases/tag/v2.44.1

Steps to reproduce the behavior

  1. Be inside a git repo in the command line
  2. Create a new variable for the repo with gh set a
  3. Update the variable using gh set a
  4. Return message is ✓ Created variable a for xxx/yyy

If you do the same for an environment level or organisation level variable it correctly returns the Updated response.

Logs

PS C:\Users\Dean\Projects\TEMPO> gh variable list
no variables found
PS C:\Users\Dean\Projects\TEMPO> gh variable list --env devo
no variables found
PS C:\Users\Dean\Projects\TEMPO> gh variable set a
? Paste your variable a

? Paste your variable a

✓ Created variable a for Naedish/TEMPO
PS C:\Users\Dean\Projects\TEMPO> gh variable set a
? Paste your variable a

? Paste your variable a

✓ Created variable a for Naedish/TEMPO
PS C:\Users\Dean\Projects\TEMPO> gh variable set a --env devo
? Paste your variable a

? Paste your variable a

✓ Created variable a for Naedish/TEMPO environment devo
PS C:\Users\Dean\Projects\TEMPO> gh variable set a --env devo
? Paste your variable a

? Paste your variable a

✓ Updated variable a for Naedish/TEMPO environment devo
PS C:\Users\Dean\Projects\TEMPO>
image

Activity

  1. Naedish commented on Feb 17, 2024

    @Naedish
    Author

    The fix is very simple - there's just an incorrect variable used in the repo section for setVariable.

    https://github.com/cli/cli/blob/trunk/pkg/cmd/variable/set/http.go#L75

  2. added
    gh-variablerelating to the gh variable command
    priority-3Affects a small number of users or is largely cosmetic
    and removed on Feb 20, 2024
  3. williammartin commented on Feb 20, 2024

    @williammartin
    Member

    Thanks for raising this bug and doing the investigation!

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-variablerelating to the gh variable 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