Skip to content

Commit 6c1dedd

Browse files
author
Osama Faqhruldin
authored
Fix repo rules bypass settings (#2831)
1 parent bedd4e3 commit 6c1dedd

5 files changed

Lines changed: 53 additions & 39 deletions

File tree

github/github-accessors.go

Lines changed: 16 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 20 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/orgs_rules_test.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ func TestOrganizationsService_GetAllOrganizationRulesets(t *testing.T) {
4444
}
4545

4646
want := []*Ruleset{{
47-
ID: 26110,
47+
ID: Int64(26110),
4848
Name: "test ruleset",
4949
Target: String("branch"),
5050
SourceType: String("Organization"),
5151
Source: "o",
5252
Enforcement: "active",
53-
BypassMode: String("none"),
5453
NodeID: String("nid"),
5554
Links: &RulesetLinks{
5655
Self: &RulesetLink{HRef: String("https://api.github.com/orgs/o/rulesets/26110")},
@@ -210,7 +209,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T)
210209

211210
ctx := context.Background()
212211
ruleset, _, err := client.Organizations.CreateOrganizationRuleset(ctx, "o", &Ruleset{
213-
ID: 21,
212+
ID: Int64(21),
214213
Name: "ruleset",
215214
Target: String("branch"),
216215
SourceType: String("Organization"),
@@ -296,7 +295,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T)
296295
}
297296

298297
want := &Ruleset{
299-
ID: 21,
298+
ID: Int64(21),
300299
Name: "ruleset",
301300
Target: String("branch"),
302301
SourceType: String("Organization"),
@@ -524,7 +523,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) {
524523

525524
ctx := context.Background()
526525
ruleset, _, err := client.Organizations.CreateOrganizationRuleset(ctx, "o", &Ruleset{
527-
ID: 21,
526+
ID: Int64(21),
528527
Name: "ruleset",
529528
Target: String("branch"),
530529
SourceType: String("Organization"),
@@ -608,7 +607,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) {
608607
}
609608

610609
want := &Ruleset{
611-
ID: 21,
610+
ID: Int64(21),
612611
Name: "ruleset",
613612
Target: String("branch"),
614613
SourceType: String("Organization"),
@@ -758,13 +757,12 @@ func TestOrganizationsService_GetOrganizationRuleset(t *testing.T) {
758757
}
759758

760759
want := &Ruleset{
761-
ID: 26110,
760+
ID: Int64(26110),
762761
Name: "test ruleset",
763762
Target: String("branch"),
764763
SourceType: String("Organization"),
765764
Source: "o",
766765
Enforcement: "active",
767-
BypassMode: String("none"),
768766
NodeID: String("nid"),
769767
Links: &RulesetLinks{
770768
Self: &RulesetLink{HRef: String("https://api.github.com/orgs/o/rulesets/26110")},
@@ -853,7 +851,6 @@ func TestOrganizationsService_UpdateOrganizationRuleset(t *testing.T) {
853851
Name: "test ruleset",
854852
Target: String("branch"),
855853
Enforcement: "active",
856-
BypassMode: String("none"),
857854
Conditions: &RulesetConditions{
858855
RefName: &RulesetRefConditionParameters{
859856
Include: []string{"refs/heads/main", "refs/heads/master"},
@@ -875,13 +872,12 @@ func TestOrganizationsService_UpdateOrganizationRuleset(t *testing.T) {
875872
}
876873

877874
want := &Ruleset{
878-
ID: 26110,
875+
ID: Int64(26110),
879876
Name: "test ruleset",
880877
Target: String("branch"),
881878
SourceType: String("Organization"),
882879
Source: "o",
883880
Enforcement: "active",
884-
BypassMode: String("none"),
885881
NodeID: String("nid"),
886882
Links: &RulesetLinks{
887883
Self: &RulesetLink{HRef: String("https://api.github.com/orgs/o/rulesets/26110")},

github/repos_rules.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import (
1414
// BypassActor represents the bypass actors from a ruleset.
1515
type BypassActor struct {
1616
ActorID *int64 `json:"actor_id,omitempty"`
17-
// Possible values for ActorType are: Team, Integration
17+
// Possible values for ActorType are: RepositoryRole, Team, Integration, OrganizationAdmin
1818
ActorType *string `json:"actor_type,omitempty"`
19+
// Possible values for BypassMode are: always, pull_request
20+
BypassMode *string `json:"bypass_mode,omitempty"`
1921
}
2022

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

320322
// Ruleset represents a GitHub ruleset object.
321323
type Ruleset struct {
322-
ID int64 `json:"id"`
324+
ID *int64 `json:"id,omitempty"`
323325
Name string `json:"name"`
324326
// Possible values for Target are branch, tag
325327
Target *string `json:"target,omitempty"`
326328
// Possible values for SourceType are: Repository, Organization
327329
SourceType *string `json:"source_type,omitempty"`
328330
Source string `json:"source"`
329331
// Possible values for Enforcement are: disabled, active, evaluate
330-
Enforcement string `json:"enforcement"`
331-
// Possible values for BypassMode are: none, repository, organization
332-
BypassMode *string `json:"bypass_mode,omitempty"`
332+
Enforcement string `json:"enforcement"`
333333
BypassActors []*BypassActor `json:"bypass_actors,omitempty"`
334334
NodeID *string `json:"node_id,omitempty"`
335335
Links *RulesetLinks `json:"_links,omitempty"`

github/repos_rules_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,14 @@ func TestRepositoriesService_GetAllRulesets(t *testing.T) {
324324

325325
want := []*Ruleset{
326326
{
327-
ID: 42,
327+
ID: Int64(42),
328328
Name: "ruleset",
329329
SourceType: String("Repository"),
330330
Source: "o/repo",
331331
Enforcement: "enabled",
332332
},
333333
{
334-
ID: 314,
334+
ID: Int64(314),
335335
Name: "Another ruleset",
336336
SourceType: String("Repository"),
337337
Source: "o/repo",
@@ -378,7 +378,7 @@ func TestRepositoriesService_CreateRuleset(t *testing.T) {
378378
}
379379

380380
want := &Ruleset{
381-
ID: 42,
381+
ID: Int64(42),
382382
Name: "ruleset",
383383
SourceType: String("Repository"),
384384
Source: "o/repo",
@@ -421,7 +421,7 @@ func TestRepositoriesService_GetRuleset(t *testing.T) {
421421
}
422422

423423
want := &Ruleset{
424-
ID: 42,
424+
ID: Int64(42),
425425
Name: "ruleset",
426426
SourceType: String("Organization"),
427427
Source: "o",
@@ -467,7 +467,7 @@ func TestRepositoriesService_UpdateRuleset(t *testing.T) {
467467
}
468468

469469
want := &Ruleset{
470-
ID: 42,
470+
ID: Int64(42),
471471
Name: "ruleset",
472472
SourceType: String("Repository"),
473473
Source: "o/repo",

0 commit comments

Comments
 (0)