Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix old_name field in AuditEntry #2849

Merged
merged 7 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions github/github-accessors.go

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

20 changes: 10 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"`

AuditEntryData `json:"data,omitempty"`
lmartinking marked this conversation as resolved.
Show resolved Hide resolved
}

// Some audit entries have additional information stuffed into a `data` field.
lmartinking marked this conversation as resolved.
Show resolved Hide resolved
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),
AuditEntryData: 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