diff --git a/github/github-accessors.go b/github/github-accessors.go index e8d4e1ac4c1..942ec6a96bd 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1278,6 +1278,14 @@ func (a *AuditEntry) GetOAuthApplicationID() int64 { return *a.OAuthApplicationID } +// GetOldName returns the OldName field if it's non-nil, zero value otherwise. +func (a *AuditEntry) GetOldName() string { + if a == nil || a.OldName == nil { + return "" + } + return *a.OldName +} + // GetOldPermission returns the OldPermission field if it's non-nil, zero value otherwise. func (a *AuditEntry) GetOldPermission() string { if a == nil || a.OldPermission == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 2385aeb08ba..4eafaf25229 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1514,6 +1514,16 @@ func TestAuditEntry_GetOAuthApplicationID(tt *testing.T) { a.GetOAuthApplicationID() } +func TestAuditEntry_GetOldName(tt *testing.T) { + var zeroValue string + a := &AuditEntry{OldName: &zeroValue} + a.GetOldName() + a = &AuditEntry{} + a.GetOldName() + a = nil + a.GetOldName() +} + func TestAuditEntry_GetOldPermission(tt *testing.T) { var zeroValue string a := &AuditEntry{OldPermission: &zeroValue} diff --git a/github/orgs_audit_log.go b/github/orgs_audit_log.go index e2e4692e570..a86910533b1 100644 --- a/github/orgs_audit_log.go +++ b/github/orgs_audit_log.go @@ -78,6 +78,7 @@ type AuditEntry struct { Message *string `json:"message,omitempty"` Name *string `json:"name,omitempty"` OAuthApplicationID *int64 `json:"oauth_application_id,omitempty"` + OldName *string `json:"old_name,omitempty"` // The previous name of the repository, for a name change OldUser *string `json:"old_user,omitempty"` OldPermission *string `json:"old_permission,omitempty"` // The permission level for membership changes, for example `admin` or `read`. OpenSSHPublicKey *string `json:"openssh_public_key,omitempty"` diff --git a/github/orgs_audit_log_test.go b/github/orgs_audit_log_test.go index 8d33a986a17..a5873ee4d38 100644 --- a/github/orgs_audit_log_test.go +++ b/github/orgs_audit_log_test.go @@ -256,6 +256,7 @@ func TestAuditEntry_Marshal(t *testing.T) { LimitedAvailability: Bool(false), Message: String("m"), Name: String("n"), + OldName: String("on"), OldPermission: String("op"), OldUser: String("ou"), OpenSSHPublicKey: String("osshpk"), @@ -345,6 +346,7 @@ func TestAuditEntry_Marshal(t *testing.T) { "limited_availability": false, "message": "m", "name": "n", + "old_name": "on", "old_permission": "op", "old_user": "ou", "openssh_public_key": "osshpk",