You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is to implement the command necessary to view a 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.
Acceptance Criteria
Note
Successful commands should return 0 exit code whereas errors should return 1 unless otherwise stated.
When I run gh repo autolink view --help Then I see an informative help usage containing descriptive command information:
Long description explaining command purpose.
Usage: gh repo autolink view <id> [flags]
Flags:
-q, --jq expression Filter JSON output using a jq expression
--json fields Output JSON with the specified fields
-t, --template string Format JSON output using a Go template; see "gh help formatting"
Inherited flags:
INHERITED FLAGS
--help Show help for command
-R, --repo [HOST/]OWNER/REPO Select another repository using the [HOST/]OWNER/REPO format
The web UI does not provide a route representing a single autolink, so we don't provide a --web flag here.
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 view <id> Then I see an informative error
error getting autolink: HTTP 404: Either no autolink with this ID exists for this repository or you are missing admin rights to the repository. (https://api.github.com/repos/{owner}/{repo}/autolinks)
The REST API provides identical 404 responses for (1) repo doesn't exist, (2) repo exists but autolink doesn't, and (3) both exists but user lacks admin rights.
When I run gh repo autolink view without an argument Then I see an informative error
accepts 1 arg(s), received 0
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 view <id> where <id> is the ID of an autolink in the repository. Then I see a message of the following form:
Given I have a repository with an autolink When I run gh repo autolink view --json Then I see a list of repository autolink fields that can be outputted in JSON format:
Specify one or more comma-separated fields for `--json`:
id
isAlphanumeric
keyPrefix
urlTemplate
Given I have a repository with an autolink When I run gh repo autolink view <id> --json <field>[,<field>...] with one or more relevant fields Then I see a JSON representation of the autolink only containing the specified fields:
Given I have a repository with an autolink When I run gh repo autolink view <id> --json <field>[,<field>...] --jq '...' with a valid jq filter Then I see the JSON result from applying the jq filter to the standard gh repo autolink --json <field>[,<field>...] result:
gh repo autolink list --json keyPrefix --jq '.keyPrefix'
resulting in:
TICKET-
Given I have a repository with an autolink When I run gh repo autolink view <id> --json <field>[,<field>...] --template '...' with a Go template Then I see the formatted JSON result from applying the template Go template filter to the standard gh repo autolink view <id> --json <field>[,<field>...] result
This issue is to implement the command necessary to view a 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.
Acceptance Criteria
Note
Successful commands should return
0exit code whereas errors should return1unless otherwise stated.When I run
gh repo autolink view --helpThen I see an informative help usage containing descriptive command information:
Long description explaining command purpose.
Usage:
gh repo autolink view <id> [flags]Flags:
The web UI does not provide a route representing a single autolink, so we don't provide a
--webflag here.Given I don't have the
adminrole on the repositoryAnd Given I have a local repository cloned from GitHub
When I run
gh repo autolink view <id>Then I see an informative error
The REST API provides identical 404 responses for (1) repo doesn't exist, (2) repo exists but autolink doesn't, and (3) both exists but user lacks admin rights.
When I run
gh repo autolink viewwithout an argumentThen I see an informative error
Given I have the
adminrole on the repositoryAnd Given I have a local repository cloned from GitHub
When I run
gh repo autolink view <id>where<id>is the ID of an autolink in the repository.Then I see a message of the following form:
Given I have a repository with an autolink
When I run
gh repo autolink view --jsonThen I see a list of repository autolink fields that can be outputted in JSON format:
Given I have a repository with an autolink
When I run
gh repo autolink view <id> --json <field>[,<field>...]with one or more relevant fieldsThen I see a JSON representation of the autolink only containing the specified fields:
Given I have a repository with an autolink
When I run
gh repo autolink view <id> --json <field>[,<field>...] --jq '...'with a validjqfilterThen I see the JSON result from applying the
jqfilter to the standardgh repo autolink --json <field>[,<field>...]result:resulting in:
Given I have a repository with an autolink
When I run
gh repo autolink view <id> --json <field>[,<field>...] --template '...'with a Go templateThen I see the formatted JSON result from applying the
templateGo template filter to the standardgh repo autolink view <id> --json <field>[,<field>...]result