From d47936fec3c94de5b655df9d9da717a7d9137ce2 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Fri, 15 Dec 2023 18:55:20 +0100 Subject: [PATCH] Add Referrer field to AuditEntry (#3032) Fixes: #3031. --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ github/orgs_audit_log.go | 1 + 3 files changed, 19 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index 4cb34b1260a..b13ed4083ff 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1454,6 +1454,14 @@ func (a *AuditEntry) GetReadOnly() string { return *a.ReadOnly } +// GetReferrer returns the Referrer field if it's non-nil, zero value otherwise. +func (a *AuditEntry) GetReferrer() string { + if a == nil || a.Referrer == nil { + return "" + } + return *a.Referrer +} + // GetRepo returns the Repo field if it's non-nil, zero value otherwise. func (a *AuditEntry) GetRepo() string { if a == nil || a.Repo == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index cdc27ab9966..c8bd40b5333 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1731,6 +1731,16 @@ func TestAuditEntry_GetReadOnly(tt *testing.T) { a.GetReadOnly() } +func TestAuditEntry_GetReferrer(tt *testing.T) { + var zeroValue string + a := &AuditEntry{Referrer: &zeroValue} + a.GetReferrer() + a = &AuditEntry{} + a.GetReferrer() + a = nil + a.GetReferrer() +} + func TestAuditEntry_GetRepo(tt *testing.T) { var zeroValue string a := &AuditEntry{Repo: &zeroValue} diff --git a/github/orgs_audit_log.go b/github/orgs_audit_log.go index e3afd3117f5..aa3591359ef 100644 --- a/github/orgs_audit_log.go +++ b/github/orgs_audit_log.go @@ -95,6 +95,7 @@ type AuditEntry struct { PullRequestURL *string `json:"pull_request_url,omitempty"` ReadOnly *string `json:"read_only,omitempty"` Reasons []*PolicyOverrideReason `json:"reasons,omitempty"` + Referrer *string `json:"referrer,omitempty"` Repo *string `json:"repo,omitempty"` Repository *string `json:"repository,omitempty"` RepositoryPublic *bool `json:"repository_public,omitempty"`