-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support choose email when creating a commit via web UI (more) (#33445)
Follow #33432
- Loading branch information
1 parent
b57d9f4
commit 5a7b42d
Showing
18 changed files
with
226 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2025 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package repo | ||
|
||
import ( | ||
user_model "code.gitea.io/gitea/models/user" | ||
"code.gitea.io/gitea/modules/log" | ||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/modules/util" | ||
"code.gitea.io/gitea/services/context" | ||
files_service "code.gitea.io/gitea/services/repository/files" | ||
) | ||
|
||
func WebGitOperationCommonData(ctx *context.Context) { | ||
// TODO: more places like "wiki page" and "merging a pull request or creating an auto merge merging task" | ||
emails, err := user_model.GetActivatedEmailAddresses(ctx, ctx.Doer.ID) | ||
if err != nil { | ||
log.Error("WebGitOperationCommonData: GetActivatedEmailAddresses: %v", err) | ||
} | ||
if ctx.Doer.KeepEmailPrivate { | ||
emails = append([]string{ctx.Doer.GetPlaceholderEmail()}, emails...) | ||
} | ||
ctx.Data["CommitCandidateEmails"] = emails | ||
ctx.Data["CommitDefaultEmail"] = ctx.Doer.GetEmail() | ||
} | ||
|
||
func WebGitOperationGetCommitChosenEmailIdentity(ctx *context.Context, email string) (_ *files_service.IdentityOptions, valid bool) { | ||
if ctx.Data["CommitCandidateEmails"] == nil { | ||
setting.PanicInDevOrTesting("no CommitCandidateEmails in context data") | ||
} | ||
emails, _ := ctx.Data["CommitCandidateEmails"].([]string) | ||
if email == "" { | ||
return nil, true | ||
} | ||
if util.SliceContainsString(emails, email, true) { | ||
return &files_service.IdentityOptions{GitUserEmail: email}, true | ||
} | ||
return nil, false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
tests/gitea-repositories-meta/user2/test_commit_revert.git/HEAD
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
tests/gitea-repositories-meta/user2/test_commit_revert.git/config
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-1.24 KB
...er2/test_commit_revert.git/objects/pack/pack-91200c8e6707636a6cc3e0d8101fba08b19dcb91.idx
Binary file not shown.
Binary file removed
BIN
-609 Bytes
...r2/test_commit_revert.git/objects/pack/pack-91200c8e6707636a6cc3e0d8101fba08b19dcb91.pack
Binary file not shown.
3 changes: 0 additions & 3 deletions
3
tests/gitea-repositories-meta/user2/test_commit_revert.git/packed-refs
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
tests/gitea-repositories-meta/user2/test_commit_revert.git/refs/heads/main
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.