Skip to content

Commit

Permalink
Fix old_name field in AuditEntry (#2849)
Browse files Browse the repository at this point in the history
Relates to: #2843.
  • Loading branch information
lmartinking authored Jul 28, 2023
1 parent c8c34d0 commit 44d09ce
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 22 deletions.
24 changes: 16 additions & 8 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 17 additions & 10 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion github/orgs_audit_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ 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"`
Expand Down Expand Up @@ -122,6 +121,13 @@ type AuditEntry struct {
Visibility *string `json:"visibility,omitempty"` // The repository visibility, for example `public` or `private`.
WorkflowID *int64 `json:"workflow_id,omitempty"`
WorkflowRunID *int64 `json:"workflow_run_id,omitempty"`

Data *AuditEntryData `json:"data,omitempty"`
}

// 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
}

// GetAuditLog gets the audit-log entries for an organization.
Expand Down
10 changes: 7 additions & 3 deletions github/orgs_audit_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ 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"),
Expand Down Expand Up @@ -300,6 +299,9 @@ func TestAuditEntry_Marshal(t *testing.T) {
Visibility: String("v"),
WorkflowID: Int64(1),
WorkflowRunID: Int64(1),
Data: &AuditEntryData{
OldName: String("on"),
},
}

want := `{
Expand Down Expand Up @@ -346,7 +348,6 @@ 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",
Expand Down Expand Up @@ -393,7 +394,10 @@ func TestAuditEntry_Marshal(t *testing.T) {
"user_agent": "ua",
"visibility": "v",
"workflow_id": 1,
"workflow_run_id": 1
"workflow_run_id": 1,
"data": {
"old_name": "on"
}
}`

testJSONMarshal(t, u, want)
Expand Down

0 comments on commit 44d09ce

Please sign in to comment.