Skip to content

Commit 6f06eac

Browse files
authored
Merge branch 'trunk' into jtmcg/testscripts-auth
2 parents 0be0fd2 + fd56fec commit 6f06eac

9 files changed

Lines changed: 243 additions & 6 deletions

File tree

acceptance/acceptance_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ func TestSecrets(t *testing.T) {
108108
testscript.Run(t, testScriptParamsFor(tsEnv, "secret"))
109109
}
110110

111+
func TestVariables(t *testing.T) {
112+
var tsEnv testScriptEnv
113+
if err := tsEnv.fromEnv(); err != nil {
114+
t.Fatal(err)
115+
}
116+
117+
testscript.Run(t, testScriptParamsFor(tsEnv, "variable"))
118+
}
119+
111120
func testScriptParamsFor(tsEnv testScriptEnv, command string) testscript.Params {
112121
var files []string
113122
if tsEnv.script != "" {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Setup environment variables used for testscript
2+
env2upper VAR_NAME=${SCRIPT_NAME}_${RANDOM_STRING}
3+
4+
# Confirm organization variable does not exist, will fail admin:org scope missing
5+
exec gh variable list --org $ORG
6+
! stdout $VAR_NAME
7+
8+
# Create an organization variable
9+
exec gh variable set $VAR_NAME --org $ORG --body 'just an org variable'
10+
11+
# Defer organization variable cleanup
12+
defer gh variable delete $VAR_NAME --org $ORG
13+
14+
# Verify new organization variable exists
15+
exec gh variable list --org $ORG
16+
stdout $VAR_NAME
17+
18+
# Verify organization variable can be retrieved
19+
exec gh variable get $VAR_NAME --org $ORG
20+
stdout 'just an org variable'
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Setup environment variables used for testscript
2+
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}
3+
env ENV_NAME=testscripts
4+
env VAR_NAME=TESTSCRIPTS_ENV
5+
6+
# Create a repository where the variable will be registered
7+
exec gh repo create $ORG/$REPO --add-readme --private
8+
9+
# Defer repo cleanup
10+
defer gh repo delete --yes $ORG/$REPO
11+
12+
# Clone the repo
13+
exec gh repo clone $ORG/$REPO
14+
cd $REPO
15+
16+
# Create a repository environment, will fail if organization does not have environment support
17+
exec gh api /repos/$ORG/$REPO/environments/$ENV_NAME -X PUT --jq '.name'
18+
19+
# Verify repository environment variable does not exist
20+
exec gh variable list --env $ENV_NAME
21+
! stdout $VAR_NAME
22+
23+
# Create a repository environment variable
24+
exec gh variable set $VAR_NAME --env $ENV_NAME --body 'just a repo env variable'
25+
26+
# Verify new repository environment variable exists
27+
exec gh variable list --env $ENV_NAME
28+
stdout $VAR_NAME
29+
30+
# Verify repository environment variable can be retrieved
31+
exec gh variable get $VAR_NAME --env $ENV_NAME
32+
stdout 'just a repo env variable'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Setup environment variables used for testscript
2+
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}
3+
env VAR_NAME=TESTSCRIPTS
4+
5+
# Create a repository where the variable will be registered
6+
exec gh repo create $ORG/$REPO --add-readme --private
7+
8+
# Defer repo cleanup
9+
defer gh repo delete --yes $ORG/$REPO
10+
11+
# Clone the repo
12+
exec gh repo clone $ORG/$REPO
13+
cd $REPO
14+
15+
# Verify repository variable does not exist
16+
exec gh variable list
17+
! stdout $VAR_NAME
18+
19+
# Create a repository variable
20+
exec gh variable set $VAR_NAME --body 'just a repo variable'
21+
22+
# Verify new repository variable exists
23+
exec gh variable list
24+
stdout $VAR_NAME
25+
26+
# Verify repository variable can be retrieved
27+
exec gh variable get $VAR_NAME
28+
stdout 'just a repo variable'

api/queries_repo.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ type Repository struct {
4141
MirrorURL string
4242
SecurityPolicyURL string
4343

44-
CreatedAt time.Time
45-
PushedAt *time.Time
46-
UpdatedAt time.Time
44+
CreatedAt time.Time
45+
PushedAt *time.Time
46+
UpdatedAt time.Time
47+
ArchivedAt *time.Time
4748

4849
IsBlankIssuesEnabled bool
4950
IsSecurityPolicyEnabled bool

api/query_builder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ var RepositoryFields = []string{
400400
"createdAt",
401401
"pushedAt",
402402
"updatedAt",
403+
"archivedAt",
403404

404405
"isBlankIssuesEnabled",
405406
"isSecurityPolicyEnabled",

docs/working-with-us.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ Describe how your new command would be used. Include mock-up examples, including
2525

2626
We take this step seriously because we believe in keeping `gh`'s interface consistent and intuitive.
2727

28-
## Step 2: Beta
28+
## Step 2: Public Preview
2929

30-
Once we've signed off on the proposed UX on the issue opened in step 1, develop your extension to at least beta quality. It's up to you if you actually want to go through a beta release phase with real users or not.
30+
Once we've signed off on the proposed UX on the issue opened in step 1, develop your extension to at least public preview quality. It's up to you if you actually want to go through a public preview release phase with real users or not.
3131

3232
## Step 3: Merge or no merge
3333

34-
With a beta in hand it's time to decide whether or not to mainline your extension into the `trunk` of `gh`. Some questions to consider:
34+
With a public preview in hand it's time to decide whether or not to mainline your extension into the `trunk` of `gh`. Some questions to consider:
3535

3636
- How complex is the support burden for your feature?
3737

pkg/cmd/repo/list/list_test.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,82 @@ import (
1919
"github.com/cli/cli/v2/pkg/cmdutil"
2020
"github.com/cli/cli/v2/pkg/httpmock"
2121
"github.com/cli/cli/v2/pkg/iostreams"
22+
"github.com/cli/cli/v2/pkg/jsonfieldstest"
2223
"github.com/cli/cli/v2/test"
2324
)
2425

26+
func TestJSONFields(t *testing.T) {
27+
jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdList, []string{
28+
"archivedAt",
29+
"assignableUsers",
30+
"codeOfConduct",
31+
"contactLinks",
32+
"createdAt",
33+
"defaultBranchRef",
34+
"deleteBranchOnMerge",
35+
"description",
36+
"diskUsage",
37+
"forkCount",
38+
"fundingLinks",
39+
"hasDiscussionsEnabled",
40+
"hasIssuesEnabled",
41+
"hasProjectsEnabled",
42+
"hasWikiEnabled",
43+
"homepageUrl",
44+
"id",
45+
"isArchived",
46+
"isBlankIssuesEnabled",
47+
"isEmpty",
48+
"isFork",
49+
"isInOrganization",
50+
"isMirror",
51+
"isPrivate",
52+
"isSecurityPolicyEnabled",
53+
"isTemplate",
54+
"isUserConfigurationRepository",
55+
"issueTemplates",
56+
"issues",
57+
"labels",
58+
"languages",
59+
"latestRelease",
60+
"licenseInfo",
61+
"mentionableUsers",
62+
"mergeCommitAllowed",
63+
"milestones",
64+
"mirrorUrl",
65+
"name",
66+
"nameWithOwner",
67+
"openGraphImageUrl",
68+
"owner",
69+
"parent",
70+
"primaryLanguage",
71+
"projects",
72+
"projectsV2",
73+
"pullRequestTemplates",
74+
"pullRequests",
75+
"pushedAt",
76+
"rebaseMergeAllowed",
77+
"repositoryTopics",
78+
"securityPolicyUrl",
79+
"sshUrl",
80+
"squashMergeAllowed",
81+
"stargazerCount",
82+
"templateRepository",
83+
"updatedAt",
84+
"url",
85+
"usesCustomOpenGraphImage",
86+
"viewerCanAdminister",
87+
"viewerDefaultCommitEmail",
88+
"viewerDefaultMergeMethod",
89+
"viewerHasStarred",
90+
"viewerPermission",
91+
"viewerPossibleCommitEmails",
92+
"viewerSubscription",
93+
"visibility",
94+
"watchers",
95+
})
96+
}
97+
2598
func TestNewCmdList(t *testing.T) {
2699
tests := []struct {
27100
name string

pkg/cmd/repo/view/view_test.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,83 @@ import (
1616
"github.com/cli/cli/v2/pkg/cmdutil"
1717
"github.com/cli/cli/v2/pkg/httpmock"
1818
"github.com/cli/cli/v2/pkg/iostreams"
19+
"github.com/cli/cli/v2/pkg/jsonfieldstest"
1920
"github.com/google/shlex"
2021
"github.com/stretchr/testify/assert"
2122
)
2223

24+
func TestJSONFields(t *testing.T) {
25+
jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdView, []string{
26+
"archivedAt",
27+
"assignableUsers",
28+
"codeOfConduct",
29+
"contactLinks",
30+
"createdAt",
31+
"defaultBranchRef",
32+
"deleteBranchOnMerge",
33+
"description",
34+
"diskUsage",
35+
"forkCount",
36+
"fundingLinks",
37+
"hasDiscussionsEnabled",
38+
"hasIssuesEnabled",
39+
"hasProjectsEnabled",
40+
"hasWikiEnabled",
41+
"homepageUrl",
42+
"id",
43+
"isArchived",
44+
"isBlankIssuesEnabled",
45+
"isEmpty",
46+
"isFork",
47+
"isInOrganization",
48+
"isMirror",
49+
"isPrivate",
50+
"isSecurityPolicyEnabled",
51+
"isTemplate",
52+
"isUserConfigurationRepository",
53+
"issueTemplates",
54+
"issues",
55+
"labels",
56+
"languages",
57+
"latestRelease",
58+
"licenseInfo",
59+
"mentionableUsers",
60+
"mergeCommitAllowed",
61+
"milestones",
62+
"mirrorUrl",
63+
"name",
64+
"nameWithOwner",
65+
"openGraphImageUrl",
66+
"owner",
67+
"parent",
68+
"primaryLanguage",
69+
"projects",
70+
"projectsV2",
71+
"pullRequestTemplates",
72+
"pullRequests",
73+
"pushedAt",
74+
"rebaseMergeAllowed",
75+
"repositoryTopics",
76+
"securityPolicyUrl",
77+
"sshUrl",
78+
"squashMergeAllowed",
79+
"stargazerCount",
80+
"templateRepository",
81+
"updatedAt",
82+
"url",
83+
"usesCustomOpenGraphImage",
84+
"viewerCanAdminister",
85+
"viewerDefaultCommitEmail",
86+
"viewerDefaultMergeMethod",
87+
"viewerHasStarred",
88+
"viewerPermission",
89+
"viewerPossibleCommitEmails",
90+
"viewerSubscription",
91+
"visibility",
92+
"watchers",
93+
})
94+
}
95+
2396
func TestNewCmdView(t *testing.T) {
2497
tests := []struct {
2598
name string

0 commit comments

Comments
 (0)