File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Create a repository to hold the autolink references
2+ exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private
3+
4+ # Defer repo cleanup
5+ defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING
6+
7+ # List the autolinks. There should be none
8+ exec gh repo autolink list --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=keyPrefix
9+ ! stdout keyPrefix
10+
11+ # Create an alphanumeric autolink
12+ exec gh repo autolink create --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING TICKET- 'https://example.com/TICKET?query=<num>'
13+
14+ # Ensure the autolink was created
15+ exec gh repo autolink list --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=keyPrefix --jq='.[].keyPrefix'
16+ stdout 'TICKET-'
17+
18+ # Get the autolink id
19+ exec gh repo autolink list --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=keyPrefix,id --jq='.[] | select(.keyPrefix == "TICKET-") | .id'
20+ stdout2env AUTOLINK_ID
21+
22+ # View the autolink and ensure the url template round tripped
23+ exec gh repo autolink view --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING $AUTOLINK_ID --json=urlTemplate --jq='.urlTemplate'
24+ stdout 'https://example\.com/TICKET\?query=<num>'
25+
26+ # Delete the autolink
27+ exec gh repo autolink delete --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING $AUTOLINK_ID --yes
28+
29+ # Ensure the autolink was deleted
30+ exec gh repo autolink list --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=id --jq='.[].id'
31+ ! stdout $AUTOLINK_ID
You can’t perform that action at this time.
0 commit comments