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

Change 'committer' field from UserID to Email, when Email is available #6912

Merged
merged 4 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2382,12 +2382,11 @@ func (c *Controller) ImportStart(w http.ResponseWriter, r *http.Request, body ap
})
}

committer := user.Username
importID, err := c.Catalog.Import(r.Context(), repository, branch, catalog.ImportRequest{
Paths: paths,
Commit: catalog.ImportCommit{
CommitMessage: body.Commit.Message,
Committer: committer,
Committer: user.Committer(),
Metadata: metadata,
},
})
Expand Down Expand Up @@ -2488,8 +2487,8 @@ func (c *Controller) Commit(w http.ResponseWriter, r *http.Request, body apigen.
if body.Metadata != nil {
metadata = body.Metadata.AdditionalProperties
}
committer := user.Username
newCommit, err := c.Catalog.Commit(ctx, repository, branch, body.Message, committer, metadata, body.Date, params.SourceMetarange)

newCommit, err := c.Catalog.Commit(ctx, repository, branch, body.Message, user.Committer(), metadata, body.Date, params.SourceMetarange)
var hookAbortErr *graveler.HookAbortError
if errors.As(err, &hookAbortErr) {
c.Logger.
Expand Down Expand Up @@ -2916,10 +2915,9 @@ func (c *Controller) RevertBranch(w http.ResponseWriter, r *http.Request, body a
writeError(w, r, http.StatusUnauthorized, "user not found")
return
}
committer := user.Username
err = c.Catalog.Revert(ctx, repository, branch, catalog.RevertParams{
Reference: body.Ref,
Committer: committer,
Committer: user.Committer(),
ParentNumber: body.ParentNumber,
})
if c.handleAPIError(ctx, w, r, err) {
Expand Down Expand Up @@ -2955,10 +2953,9 @@ func (c *Controller) CherryPick(w http.ResponseWriter, r *http.Request, body api
writeError(w, r, http.StatusUnauthorized, "user not found")
return
}
committer := user.Username
newCommit, err := c.Catalog.CherryPick(ctx, repository, branch, catalog.CherryPickParams{
Reference: body.Ref,
Committer: committer,
Committer: user.Committer(),
ParentNumber: body.ParentNumber,
})
if c.handleAPIError(ctx, w, r, err) {
Expand Down Expand Up @@ -3916,7 +3913,7 @@ func (c *Controller) MergeIntoBranch(w http.ResponseWriter, r *http.Request, bod

reference, err := c.Catalog.Merge(ctx,
repository, destinationBranch, sourceRef,
user.Username,
user.Committer(),
swag.StringValue(body.Message),
metadata,
swag.StringValue(body.Strategy))
Expand Down
7 changes: 7 additions & 0 deletions pkg/auth/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ type User struct {
ExternalID *string `db:"external_id" json:"external_id"`
}

func (u *User) Committer() string {
if u.Email != nil {
return *u.Email
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also verify the value is not empty string?

}
return u.Username
}

type DBUser struct {
ID int64 `db:"id"`
User
Expand Down
Loading