Skip to content

Commit

Permalink
Merge branch 'master' into feat/sleep_until_primary_rate_limit
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah authored Apr 19, 2024
2 parents 960ce81 + 8d4be0b commit ea82df3
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ jobs:

- name: Upload coverage to Codecov
if: ${{ matrix.update-coverage }}
uses: codecov/codecov-action@7afa10ed9b269c561c2336fd862446844e0cbf71 #v4.2.0
uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed #v4.3.0
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ Matt Gaunt <[email protected]>
Matt Landis <[email protected]>
Matt Moore <[email protected]>
Matt Simons <[email protected]>
Matthew Reidy <[email protected]>
Maxime Bury <[email protected]>
Michael Meng <[email protected]>
Michael Spiegel <[email protected]>
Expand Down Expand Up @@ -484,4 +485,4 @@ Zach Latta <[email protected]>
zhouhaibing089 <[email protected]>
六开箱 <[email protected]>
缘生 <[email protected]>
蒋航 <[email protected]>
蒋航 <[email protected]>
8 changes: 4 additions & 4 deletions example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require (
github.com/bradleyfalzon/ghinstallation/v2 v2.0.4
github.com/gofri/go-github-ratelimit v1.0.3
github.com/google/go-github/v61 v61.0.0
golang.org/x/crypto v0.17.0
golang.org/x/term v0.15.0
golang.org/x/crypto v0.21.0
golang.org/x/term v0.18.0
google.golang.org/appengine v1.6.7
)

Expand All @@ -18,8 +18,8 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-github/v41 v41.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)

Expand Down
16 changes: 8 additions & 8 deletions example/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
Expand All @@ -41,8 +41,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -56,15 +56,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
10 changes: 10 additions & 0 deletions github/orgs_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T)
{
"type": "deletion"
},
{
"type": "merge_queue"
},
{
"type": "required_linear_history"
},
Expand Down Expand Up @@ -238,6 +241,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T)
UpdateAllowsFetchAndMerge: true,
}),
NewDeletionRule(),
NewMergeQueueRule(),
NewRequiredLinearHistoryRule(),
NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{
RequiredDeploymentEnvironments: []string{"test"},
Expand Down Expand Up @@ -324,6 +328,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T)
UpdateAllowsFetchAndMerge: true,
}),
NewDeletionRule(),
NewMergeQueueRule(),
NewRequiredLinearHistoryRule(),
NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{
RequiredDeploymentEnvironments: []string{"test"},
Expand Down Expand Up @@ -437,6 +442,9 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) {
{
"type": "deletion"
},
{
"type": "merge_queue"
},
{
"type": "required_linear_history"
},
Expand Down Expand Up @@ -550,6 +558,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) {
UpdateAllowsFetchAndMerge: true,
}),
NewDeletionRule(),
NewMergeQueueRule(),
NewRequiredLinearHistoryRule(),
NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{
RequiredDeploymentEnvironments: []string{"test"},
Expand Down Expand Up @@ -634,6 +643,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) {
UpdateAllowsFetchAndMerge: true,
}),
NewDeletionRule(),
NewMergeQueueRule(),
NewRequiredLinearHistoryRule(),
NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{
RequiredDeploymentEnvironments: []string{"test"},
Expand Down
9 changes: 8 additions & 1 deletion github/repos_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error {
r.Type = RepositoryRule.Type

switch RepositoryRule.Type {
case "creation", "deletion", "required_linear_history", "required_signatures", "non_fast_forward":
case "creation", "deletion", "merge_queue", "non_fast_forward", "required_linear_history", "required_signatures":
r.Parameters = nil
case "update":
if RepositoryRule.Parameters == nil {
Expand Down Expand Up @@ -210,6 +210,13 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error {
return nil
}

// NewMergeQueueRule creates a rule to only allow merges via a merge queue.
func NewMergeQueueRule() (rule *RepositoryRule) {
return &RepositoryRule{
Type: "merge_queue",
}
}

// NewCreationRule creates a rule to only allow users with bypass permission to create matching refs.
func NewCreationRule() (rule *RepositoryRule) {
return &RepositoryRule{
Expand Down
7 changes: 7 additions & 0 deletions github/repos_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ func TestRepositoryRule_UnmarshalJSON(t *testing.T) {
Parameters: nil,
},
},
"Valid merge_queue": {
data: `{"type":"merge_queue"}`,
want: &RepositoryRule{
Type: "merge_queue",
Parameters: nil,
},
},
"Valid non_fast_forward": {
data: `{"type":"non_fast_forward"}`,
want: &RepositoryRule{
Expand Down

0 comments on commit ea82df3

Please sign in to comment.