Skip to content

Add support for gh repo autolink delete #10120

@andyfeller

Description

@andyfeller

This issue is to implement the command necessary to delete repository autolinks as discussed within #9420 underneath gh repo autolink.

This should follow similar form as existing GitHub CLI commands as well as necessary tests.

cc: @hoffm @nitrocode

Acceptance Criteria

Note

Successful commands should return 0 exit code whereas errors should return 1 unless otherwise stated.

When I run gh repo autolink delete --help
Then I see an informative help usage containing descriptive command information:

  1. Long description explaining command purpose

  2. Usage: gh repo autolink delete <keyPrefix> [flags]

  3. Flags:

    FLAGS
      --yes   Confirm deletion without prompting
  4. Inherited flags:

    INHERITED FLAGS
          --help                     Show help for command
      -R, --repo [HOST/]OWNER/REPO   Select another repository using the [HOST/]OWNER/REPO format

Given I have the admin role on the repository
And Given I have a local repository cloned from GitHub
When I run gh repo autolink delete <keyPrefix> in interactive mode
Then I see a prompt asking for confirmation of deleting autolink by typing keyPrefix

? Type this-is-provided-keyPrefix to confirm deletion: 

When I mistype the autolink keyPrefix
Then I see an informative error and prompted to try again to enter the autolink keyPrefix

X Sorry, your reply was invalid: You entered lkjalskdjfasdf
? Type this-is-provided-keyPrefix to confirm deletion: 

When I correctly type the autolink keyPrefix
Then I see an informational message confirming the repository autolink was deleted

✓ Autolink "<keyPrefix>" deleted from <owner>/<repo>

Given I have the admin role on the repository
And Given I have a local repository cloned from GitHub
When I run gh repo autolink delete <keyPrefix> in non-interactive mode
Then I see an informational message stating --yes flag is required to delete autolink in non-interactive mode followed by the usage statement

--yes required when not running interactively

Usage:  ...

Note

For examples, see gh label delete behavior


Given I have the admin role on the repository
And Given I have a local repository cloned from GitHub
When I run gh repo autolink delete <keyPrefix> in interactive mode
Then I see a prompt asking for confirmation of deleting autolink by typing keyPrefix


Given I don't have the admin role on the repository
And Given I have a local repository cloned from GitHub
When I run gh repo autolink delete <keyPrefix>
Then I see an informative error after confirming prompt

? Type this-is-provided-keyPrefix to confirm deletion: 
error deleting autolink: HTTP 404: Must have admin rights to Repository. (https://api.github.com/repos/{owner}/{repo}/autolinks)

Given I have the admin role on the repository
And Given I have a remote repository with autolinks
When I run gh repo autolink delete <keyPrefix> --repo <owner>/<repo> in interactive mode
Then I see a prompt asking for confirmation of deleting autolink by typing keyPrefix as when I have a local repository


Given I have the admin role on the repository
And Given I have a local repository cloned from GitHub
When I run gh repo autolink delete <keyPrefix> --yes
Then I see an informational message confirming the repository autolink was deleted without prompt asking for confirmation


Given I have the admin role on the repository
And Given I have a local repository cloned from GitHub
When I run gh repo autolink delete <keyPrefix> with a non-existent keyPrefix
Then I see an informative error after confirming prompt

? Type this-is-provided-keyPrefix to confirm deletion: 
HTTP 404: Not Found (https://api.github.com/repos/{owner}/{repo}/autolinks/this-is-provided-keyPrefix)

Metadata

Metadata

Assignees

Labels

gh-reporelating to the gh repo commandhelp wantedContributions welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions