diff --git a/pkg/cmd/ruleset/list/list_test.go b/pkg/cmd/ruleset/list/list_test.go index 2bb0e3cf7..4a01b803a 100644 --- a/pkg/cmd/ruleset/list/list_test.go +++ b/pkg/cmd/ruleset/list/list_test.go @@ -10,7 +10,6 @@ import ( "github.com/cli/cli/v2/internal/browser" "github.com/cli/cli/v2/internal/config" "github.com/cli/cli/v2/internal/ghrepo" - "github.com/cli/cli/v2/internal/run" "github.com/cli/cli/v2/pkg/cmdutil" "github.com/cli/cli/v2/pkg/httpmock" "github.com/cli/cli/v2/pkg/iostreams" @@ -137,76 +136,6 @@ func Test_NewCmdList(t *testing.T) { } } -func Test_RulesetList_Web(t *testing.T) { - tests := []struct { - name string - stdoutTTY bool - wantStdout string - wantBrowse string - }{ - { - name: "repo tty", - stdoutTTY: true, - wantStdout: "Opening github.com/OWNER/REPO in your browser.\n", - wantBrowse: "https://github.com/OWNER/REPO", - }, - { - name: "org tty", - stdoutTTY: true, - wantStdout: "Opening github.com/OWNER/REPO in your browser.\n", - wantBrowse: "https://github.com/OWNER/REPO", - }, - { - name: "repo non-tty", - stdoutTTY: false, - wantStdout: "", - wantBrowse: "https://github.com/OWNER/REPO", - }, - { - name: "org non-tty", - stdoutTTY: false, - wantStdout: "", - wantBrowse: "https://github.com/OWNER/REPO", - }, - } - - for _, tt := range tests { - reg := &httpmock.Registry{} - reg.StubRepoInfoResponse("OWNER", "REPO", "main") - - browser := &browser.Stub{} - opts := &ListOptions{ - WebMode: true, - HttpClient: func() (*http.Client, error) { - return &http.Client{Transport: reg}, nil - }, - BaseRepo: func() (ghrepo.Interface, error) { - return ghrepo.New("OWNER", "REPO"), nil - }, - Browser: browser, - } - - io, _, stdout, _ := iostreams.Test() - - opts.IO = io - - t.Run(tt.name, func(t *testing.T) { - io.SetStdoutTTY(tt.stdoutTTY) - - _, teardown := run.Stub() - defer teardown(t) - - if err := listRun(opts); err != nil { - t.Errorf("listRun() error = %v", err) - } - assert.Equal(t, "", stdout.String()) - assert.Equal(t, tt.wantStdout, stdout.String()) - reg.Verify(t) - browser.Verify(t, tt.wantBrowse) - }) - } -} - func Test_listRun(t *testing.T) { tests := []struct { name string diff --git a/pkg/cmd/ruleset/rules.go b/pkg/cmd/ruleset/rules.go deleted file mode 100644 index b3405d839..000000000 --- a/pkg/cmd/ruleset/rules.go +++ /dev/null @@ -1,39 +0,0 @@ -package ruleset - -type RuleType string -type Enforcement string -type MatchingOperator string - -const ( - RuleTypeCommitAuthorEmailPattern RuleType = "commit_author_email_pattern" - RuleTypePullRequest RuleType = "pull_request" - // TODO others - - EnforcementEnabled Enforcement = "enabled" - EnforcementDisabled Enforcement = "disabled" - - MatchingOperatorStartsWith MatchingOperator = "starts_with" - MatchingOperatorEndsWith MatchingOperator = "ends_with" - MatchingOperatorContains MatchingOperator = "contains" - MatchingOperatorRegex MatchingOperator = "regex" -) - -type ConfigurationPullRequest struct { - DissmissStaleReviewsOnPush bool - RequireCodeOwnerReview bool - RequestLastPushApproval bool - RequiredApprovingReviewCount int -} - -type BranchNamePattern struct { - Name string - Negate bool - Operator MatchingOperator -} - -type Rule struct { - ID string - Type RuleType - Enforcement Enforcement - Configuration interface{} -} diff --git a/pkg/cmd/ruleset/ruleset.go b/pkg/cmd/ruleset/ruleset.go index 64536e868..86411d717 100644 --- a/pkg/cmd/ruleset/ruleset.go +++ b/pkg/cmd/ruleset/ruleset.go @@ -12,12 +12,17 @@ import ( func NewCmdRuleset(f *cmdutil.Factory) *cobra.Command { cmd := &cobra.Command{ Use: "ruleset ", - Short: "Manage repository and organization rulesets", + Short: "View info about repo rulesets", Long: heredoc.Doc(` - TODO + Repository rulesets are a way to define a set of rules that apply to a repository. + These commands allow you to view information about them. `), Aliases: []string{"rs"}, - Example: "TODO", + Example: heredoc.Doc(` + $ gh ruleset list + $ gh ruleset view --repo OWNER/REPO --web + $ gh ruleset check branch-name + `), } cmdutil.EnableRepoOverride(cmd, f) diff --git a/pkg/cmd/ruleset/shared/shared.go b/pkg/cmd/ruleset/shared/shared.go index b365a006d..a71b20522 100644 --- a/pkg/cmd/ruleset/shared/shared.go +++ b/pkg/cmd/ruleset/shared/shared.go @@ -34,7 +34,6 @@ type RulesetREST struct { BypassMode string `json:"bypass_mode"` } `json:"bypass_actors"` Conditions map[string]map[string]interface{} - // TODO is this source field used? SourceType string `json:"source_type"` Source string Rules []RulesetRule