From efde92c2dbab2024f4fd1196d9d5e60cc2f13da2 Mon Sep 17 00:00:00 2001 From: Lucas Martin-King Date: Sat, 29 Jul 2023 00:58:41 +1000 Subject: [PATCH 1/3] Add `OldLogin` field to `AuditEntryData` --- github/orgs_audit_log.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/github/orgs_audit_log.go b/github/orgs_audit_log.go index d7de77127c5..4c34445fa1b 100644 --- a/github/orgs_audit_log.go +++ b/github/orgs_audit_log.go @@ -127,7 +127,8 @@ type AuditEntry struct { // AuditEntryData represents additional information stuffed into a `data` field. type AuditEntryData struct { - OldName *string `json:"old_name,omitempty"` // The previous name of the repository, for a name change + OldName *string `json:"old_name,omitempty"` // The previous name of the repository, for a name change + OldLogin *string `json:"old_login,omitempty"` // The previous name of the organization, for a name change } // GetAuditLog gets the audit-log entries for an organization. From bcb0e54ad59cbb39236ebd0d0e203564bb833a64 Mon Sep 17 00:00:00 2001 From: Lucas Martin-King Date: Sat, 29 Jul 2023 00:59:02 +1000 Subject: [PATCH 2/3] update accessors --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index 356487e0e1e..3f665ede5cb 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1598,6 +1598,14 @@ func (a *AuditEntry) GetWorkflowRunID() int64 { return *a.WorkflowRunID } +// GetOldLogin returns the OldLogin field if it's non-nil, zero value otherwise. +func (a *AuditEntryData) GetOldLogin() string { + if a == nil || a.OldLogin == nil { + return "" + } + return *a.OldLogin +} + // GetOldName returns the OldName field if it's non-nil, zero value otherwise. func (a *AuditEntryData) GetOldName() string { if a == nil || a.OldName == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 40942da40b3..712d8fc94dd 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1911,6 +1911,16 @@ func TestAuditEntry_GetWorkflowRunID(tt *testing.T) { a.GetWorkflowRunID() } +func TestAuditEntryData_GetOldLogin(tt *testing.T) { + var zeroValue string + a := &AuditEntryData{OldLogin: &zeroValue} + a.GetOldLogin() + a = &AuditEntryData{} + a.GetOldLogin() + a = nil + a.GetOldLogin() +} + func TestAuditEntryData_GetOldName(tt *testing.T) { var zeroValue string a := &AuditEntryData{OldName: &zeroValue} From 61560e8b8133aa46a57f9cba34a05a65ec47f065 Mon Sep 17 00:00:00 2001 From: Lucas Martin-King Date: Sat, 29 Jul 2023 00:59:42 +1000 Subject: [PATCH 3/3] update tests --- github/orgs_audit_log_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/github/orgs_audit_log_test.go b/github/orgs_audit_log_test.go index 2995de5023c..89cdf46242e 100644 --- a/github/orgs_audit_log_test.go +++ b/github/orgs_audit_log_test.go @@ -300,7 +300,8 @@ func TestAuditEntry_Marshal(t *testing.T) { WorkflowID: Int64(1), WorkflowRunID: Int64(1), Data: &AuditEntryData{ - OldName: String("on"), + OldName: String("on"), + OldLogin: String("ol"), }, } @@ -396,7 +397,8 @@ func TestAuditEntry_Marshal(t *testing.T) { "workflow_id": 1, "workflow_run_id": 1, "data": { - "old_name": "on" + "old_name": "on", + "old_login": "ol" } }`