From c8e9a12d58f077501cca5dcfdf90549c084f582f Mon Sep 17 00:00:00 2001 From: Judson Lester Date: Fri, 3 Dec 2021 12:26:37 -0800 Subject: [PATCH 1/2] Add Installation field and accessor to BranchProtectionRuleEvent --- github/event_types.go | 13 +++++----- github/github-accessors.go | 8 +++++++ github/github-accessors_test.go | 7 ++++++ .../access-restrictions-disabled.html | 6 ++--- .../testdata/access-restrictions-enabled.html | 24 +++++++++---------- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/github/event_types.go b/github/event_types.go index 5c81115877..f63c804033 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -20,12 +20,13 @@ type RequestedAction struct { // // GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch_protection_rule type BranchProtectionRuleEvent struct { - Action *string `json:"action,omitempty"` - Rule *BranchProtectionRule `json:"rule,omitempty"` - Changes *ProtectionChanges `json:"changes,omitempty"` - Repo *Repository `json:"repository,omitempty"` - Org *Organization `json:"organization,omitempty"` - Sender *User `json:"sender,omitempty"` + Action *string `json:"action,omitempty"` + Rule *BranchProtectionRule `json:"rule,omitempty"` + Changes *ProtectionChanges `json:"changes,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Org *Organization `json:"organization,omitempty"` + Sender *User `json:"sender,omitempty"` + Installation *Installation `json:"installation,omitempty"` } // CheckRunEvent is triggered when a check run is "created", "completed", or "rerequested". diff --git a/github/github-accessors.go b/github/github-accessors.go index 8c6ebdadc0..c74f34c899 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1636,6 +1636,14 @@ func (b *BranchProtectionRuleEvent) GetSender() *User { return b.Sender } +// GetInstallation returns the Installation field. +func (b *BranchProtectionRuleEvent) GetInstallation() *Installation { + if b == nil { + return nil + } + return b.Installation +} + // GetApp returns the App field. func (c *CheckRun) GetApp() *App { if c == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 246190dc42..fa3f7c30ee 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1956,6 +1956,13 @@ func TestBranchProtectionRuleEvent_GetSender(tt *testing.T) { b.GetSender() } +func TestBranchProtectionRuleEvent_GetInstallation(tt *testing.T) { + b := &BranchProtectionRuleEvent{} + b.GetInstallation() + b = nil + b.GetInstallation() +} + func TestCheckRun_GetApp(tt *testing.T) { c := &CheckRun{} c.GetApp() diff --git a/scrape/testdata/access-restrictions-disabled.html b/scrape/testdata/access-restrictions-disabled.html index 97e8133927..a5fbe34cab 100644 --- a/scrape/testdata/access-restrictions-disabled.html +++ b/scrape/testdata/access-restrictions-disabled.html @@ -2,16 +2,16 @@ Some extraneous markup removed to keep the file size smaller --> - +
- +
- +

Third-party application access policy

diff --git a/scrape/testdata/access-restrictions-enabled.html b/scrape/testdata/access-restrictions-enabled.html index 39ef4b4cde..4b8d1db816 100644 --- a/scrape/testdata/access-restrictions-enabled.html +++ b/scrape/testdata/access-restrictions-enabled.html @@ -2,10 +2,10 @@ Some extraneous markup removed to keep the file size smaller --> - +
- +
@@ -13,7 +13,7 @@
- +

Third-party application access policy

@@ -23,24 +23,24 @@

Third-party application access policy

Only approved applications can access data in this organization. Applications owned by google-test always have access.

- +
- + Remove restrictions

Are you sure?

- +
You’re about to remove all third-party application restrictions. Please read this carefully.
@@ -69,7 +69,7 @@

Are you sure?

  • - Approval requested by willnorris — + Approval requested by willnorrisReview
    From 2f2e92d42af87d218e8b31d5602b488b21d2b093 Mon Sep 17 00:00:00 2001 From: Judson Lester Date: Fri, 3 Dec 2021 13:53:09 -0800 Subject: [PATCH 2/2] Use generated accessors --- github/github-accessors.go | 16 ++++++++-------- github/github-accessors_test.go | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index c74f34c899..166e2ad50c 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1604,6 +1604,14 @@ func (b *BranchProtectionRuleEvent) GetChanges() *ProtectionChanges { return b.Changes } +// GetInstallation returns the Installation field. +func (b *BranchProtectionRuleEvent) GetInstallation() *Installation { + if b == nil { + return nil + } + return b.Installation +} + // GetOrg returns the Org field. func (b *BranchProtectionRuleEvent) GetOrg() *Organization { if b == nil { @@ -1636,14 +1644,6 @@ func (b *BranchProtectionRuleEvent) GetSender() *User { return b.Sender } -// GetInstallation returns the Installation field. -func (b *BranchProtectionRuleEvent) GetInstallation() *Installation { - if b == nil { - return nil - } - return b.Installation -} - // GetApp returns the App field. func (c *CheckRun) GetApp() *App { if c == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index fa3f7c30ee..fa4dc56c39 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1928,6 +1928,13 @@ func TestBranchProtectionRuleEvent_GetChanges(tt *testing.T) { b.GetChanges() } +func TestBranchProtectionRuleEvent_GetInstallation(tt *testing.T) { + b := &BranchProtectionRuleEvent{} + b.GetInstallation() + b = nil + b.GetInstallation() +} + func TestBranchProtectionRuleEvent_GetOrg(tt *testing.T) { b := &BranchProtectionRuleEvent{} b.GetOrg() @@ -1956,13 +1963,6 @@ func TestBranchProtectionRuleEvent_GetSender(tt *testing.T) { b.GetSender() } -func TestBranchProtectionRuleEvent_GetInstallation(tt *testing.T) { - b := &BranchProtectionRuleEvent{} - b.GetInstallation() - b = nil - b.GetInstallation() -} - func TestCheckRun_GetApp(tt *testing.T) { c := &CheckRun{} c.GetApp()