Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 20 additions & 10 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions github/orgs_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ func TestOrganizationsService_GetAllOrganizationRulesets(t *testing.T) {
}

want := []*Ruleset{{
ID: 26110,
ID: Int64(26110),
Name: "test ruleset",
Target: String("branch"),
SourceType: String("Organization"),
Source: "o",
Enforcement: "active",
BypassMode: String("none"),
NodeID: String("nid"),
Links: &RulesetLinks{
Self: &RulesetLink{HRef: String("https://api.github.com/orgs/o/rulesets/26110")},
Expand Down Expand Up @@ -210,7 +209,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T)

ctx := context.Background()
ruleset, _, err := client.Organizations.CreateOrganizationRuleset(ctx, "o", &Ruleset{
ID: 21,
ID: Int64(21),
Name: "ruleset",
Target: String("branch"),
SourceType: String("Organization"),
Expand Down Expand Up @@ -296,7 +295,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T)
}

want := &Ruleset{
ID: 21,
ID: Int64(21),
Name: "ruleset",
Target: String("branch"),
SourceType: String("Organization"),
Expand Down Expand Up @@ -524,7 +523,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) {

ctx := context.Background()
ruleset, _, err := client.Organizations.CreateOrganizationRuleset(ctx, "o", &Ruleset{
ID: 21,
ID: Int64(21),
Name: "ruleset",
Target: String("branch"),
SourceType: String("Organization"),
Expand Down Expand Up @@ -608,7 +607,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) {
}

want := &Ruleset{
ID: 21,
ID: Int64(21),
Name: "ruleset",
Target: String("branch"),
SourceType: String("Organization"),
Expand Down Expand Up @@ -758,13 +757,12 @@ func TestOrganizationsService_GetOrganizationRuleset(t *testing.T) {
}

want := &Ruleset{
ID: 26110,
ID: Int64(26110),
Name: "test ruleset",
Target: String("branch"),
SourceType: String("Organization"),
Source: "o",
Enforcement: "active",
BypassMode: String("none"),
NodeID: String("nid"),
Links: &RulesetLinks{
Self: &RulesetLink{HRef: String("https://api.github.com/orgs/o/rulesets/26110")},
Expand Down Expand Up @@ -853,7 +851,6 @@ func TestOrganizationsService_UpdateOrganizationRuleset(t *testing.T) {
Name: "test ruleset",
Target: String("branch"),
Enforcement: "active",
BypassMode: String("none"),
Conditions: &RulesetConditions{
RefName: &RulesetRefConditionParameters{
Include: []string{"refs/heads/main", "refs/heads/master"},
Expand All @@ -875,13 +872,12 @@ func TestOrganizationsService_UpdateOrganizationRuleset(t *testing.T) {
}

want := &Ruleset{
ID: 26110,
ID: Int64(26110),
Name: "test ruleset",
Target: String("branch"),
SourceType: String("Organization"),
Source: "o",
Enforcement: "active",
BypassMode: String("none"),
NodeID: String("nid"),
Links: &RulesetLinks{
Self: &RulesetLink{HRef: String("https://api.github.com/orgs/o/rulesets/26110")},
Expand Down
10 changes: 5 additions & 5 deletions github/repos_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import (
// BypassActor represents the bypass actors from a ruleset.
type BypassActor struct {
ActorID *int64 `json:"actor_id,omitempty"`
// Possible values for ActorType are: Team, Integration
// Possible values for ActorType are: RepositoryRole, Team, Integration, OrganizationAdmin
ActorType *string `json:"actor_type,omitempty"`
// Possible values for BypassMode are: always, pull_request
BypassMode *string `json:"bypass_mode,omitempty"`
}

// RulesetLink represents a single link object from GitHub ruleset request _links.
Expand Down Expand Up @@ -319,17 +321,15 @@ func NewTagNamePatternRule(params *RulePatternParameters) (rule *RepositoryRule)

// Ruleset represents a GitHub ruleset object.
type Ruleset struct {
ID int64 `json:"id"`
ID *int64 `json:"id,omitempty"`
Name string `json:"name"`
// Possible values for Target are branch, tag
Target *string `json:"target,omitempty"`
// Possible values for SourceType are: Repository, Organization
SourceType *string `json:"source_type,omitempty"`
Source string `json:"source"`
// Possible values for Enforcement are: disabled, active, evaluate
Enforcement string `json:"enforcement"`
// Possible values for BypassMode are: none, repository, organization
BypassMode *string `json:"bypass_mode,omitempty"`
Enforcement string `json:"enforcement"`
BypassActors []*BypassActor `json:"bypass_actors,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Links *RulesetLinks `json:"_links,omitempty"`
Expand Down
10 changes: 5 additions & 5 deletions github/repos_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,14 @@ func TestRepositoriesService_GetAllRulesets(t *testing.T) {

want := []*Ruleset{
{
ID: 42,
ID: Int64(42),
Name: "ruleset",
SourceType: String("Repository"),
Source: "o/repo",
Enforcement: "enabled",
},
{
ID: 314,
ID: Int64(314),
Name: "Another ruleset",
SourceType: String("Repository"),
Source: "o/repo",
Expand Down Expand Up @@ -378,7 +378,7 @@ func TestRepositoriesService_CreateRuleset(t *testing.T) {
}

want := &Ruleset{
ID: 42,
ID: Int64(42),
Name: "ruleset",
SourceType: String("Repository"),
Source: "o/repo",
Expand Down Expand Up @@ -421,7 +421,7 @@ func TestRepositoriesService_GetRuleset(t *testing.T) {
}

want := &Ruleset{
ID: 42,
ID: Int64(42),
Name: "ruleset",
SourceType: String("Organization"),
Source: "o",
Expand Down Expand Up @@ -467,7 +467,7 @@ func TestRepositoriesService_UpdateRuleset(t *testing.T) {
}

want := &Ruleset{
ID: 42,
ID: Int64(42),
Name: "ruleset",
SourceType: String("Repository"),
Source: "o/repo",
Expand Down