Files
zeekayandHanzo Dev aa87442fdd Record upstream authorship centrally in NOTICE instead of in every file header
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the
Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in
NOTICE, alongside LICENSE. The header lint accepts any copyright line above the
SPDX line, so it no longer demands an upstream one.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-10 17:50:35 -07:00

41 lines
1.4 KiB
Go

// Copyright 2026 Hanzo AI, Inc. All rights reserved.
// SPDX-License-Identifier: MIT
package repo
import (
user_model "github.com/hanzoai/git/models/user"
"github.com/hanzoai/git/modules/log"
"github.com/hanzoai/git/modules/setting"
"github.com/hanzoai/git/modules/util"
"github.com/hanzoai/git/services/context"
files_service "github.com/hanzoai/git/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
}