Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add support for gh repo autolink view #10200

Copy link
Copy link

Description

@hoffm
Issue body actions

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:

  1. Long description explaining command purpose.

  2. Usage: gh repo autolink view <id> [flags]

  3. 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"
  1. Inherited flags:
INHERITED FLAGS
         --help                     Show help for command
     -R, --repo [HOST/]OWNER/REPO   Select another repository using the [HOST/]OWNER/REPO format
  1. JSON fields:
 JSON FIELDS
     id, isAlphanumeric, keyPrefix, urlTemplate

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:

Autolink in <owner>/<repo>

ID: <id>
Key Prefix: <keyPrefix>
URL Template: <urlTemplate>
Alphanumeric: <isAlphanumeric>

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:

{
  "id": 1,
  "isAlphanumeric": false,
  "keyPrefix": "DISCORD-",
  "urlTemplate": "https://discord.com/channels/<num>"
}

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

enhancementa request to improve CLIa request to improve CLIgh-reporelating to the gh repo commandrelating to the gh repo command

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

Morty Proxy This is a proxified and sanitized view of the page, visit original site.