-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Description
This issue is to implement the command necessary to create 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 create --help
Then I see an informative help usage containing descriptive command information:
-
Long description explaining command purpose
-
Usage:
gh repo autolink create <keyPrefix> <urlTemplate> [flags] -
Aliases:
createcommands typically allownewalias -
Flags:
-n, --numeric Mark autolink as non-alphanumeric
-
Inherited flags:
INHERITED FLAGS --help Show help for command -R, --repo [HOST/]OWNER/REPO Select another repository using the [HOST/]OWNER/REPO format -
Examples
# Create alphanumeric autolink gh repo autolink create "TICKET-" "https://example.com/TICKET?query=<num>" # Create numeric autolink gh repo autolink create "DISCORD-" "https://discord.com/channels/<num>" --numeric
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 create <keyPrefix> <urlTemplate>
Then I see an informative error
error creating 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 local repository cloned from GitHub
When I run gh repo autolink create <keyPrefix> <urlTemplate>
Then I see an informational message confirming the repository autolink was created
✓ Autolink "<keyPrefix>" created in <owner>/<repo>Given I have the admin role on the repository
And Given I have a remote repository
When I run gh repo autolink create <keyPrefix> <urlTemplate> --repo <owner>/<repo>
Then I see an informational message confirming the repository autolink was created the same 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 create <keyPrefix> <urlTemplate>
And When <urlTemplate> does not contain literal <num>
Then I see an informative error explaining <urlTemplate> must contain <num>