mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-21 09:31:19 +02:00
Enable gocritic equalFold
and fix issues (#34952)
Continuation of https://github.com/go-gitea/gitea/pull/34678. --------- Signed-off-by: silverwind <me@silverwind.io>
This commit is contained in:
@@ -241,7 +241,7 @@ func (source *Source) listLdapGroupMemberships(l *ldap.Conn, uid string, applyGr
|
||||
}
|
||||
|
||||
func (source *Source) getUserAttributeListedInGroup(entry *ldap.Entry) string {
|
||||
if strings.ToLower(source.UserUID) == "dn" {
|
||||
if strings.EqualFold(source.UserUID, "dn") {
|
||||
return entry.DN
|
||||
}
|
||||
|
||||
|
@@ -208,7 +208,7 @@ func OrgAssignment(opts OrgAssignmentOptions) func(ctx *Context) {
|
||||
if len(teamName) > 0 {
|
||||
teamExists := false
|
||||
for _, team := range ctx.Org.Teams {
|
||||
if team.LowerName == strings.ToLower(teamName) {
|
||||
if strings.EqualFold(team.LowerName, teamName) {
|
||||
teamExists = true
|
||||
ctx.Org.Team = team
|
||||
ctx.Org.IsTeamMember = true
|
||||
|
@@ -429,7 +429,7 @@ func RepoAssignment(ctx *Context) {
|
||||
}
|
||||
|
||||
// Check if the user is the same as the repository owner
|
||||
if ctx.IsSigned && ctx.Doer.LowerName == strings.ToLower(userName) {
|
||||
if ctx.IsSigned && strings.EqualFold(ctx.Doer.LowerName, userName) {
|
||||
ctx.Repo.Owner = ctx.Doer
|
||||
} else {
|
||||
ctx.Repo.Owner, err = user_model.GetUserByName(ctx, userName)
|
||||
|
@@ -61,7 +61,7 @@ func UserAssignmentAPI() func(ctx *APIContext) {
|
||||
func userAssignment(ctx *Base, doer *user_model.User, errCb func(int, any)) (contextUser *user_model.User) {
|
||||
username := ctx.PathParam("username")
|
||||
|
||||
if doer != nil && doer.LowerName == strings.ToLower(username) {
|
||||
if doer != nil && strings.EqualFold(doer.LowerName, username) {
|
||||
contextUser = doer
|
||||
} else {
|
||||
var err error
|
||||
|
@@ -144,7 +144,7 @@ func CleanGitTreePath(name string) string {
|
||||
name = util.PathJoinRel(name)
|
||||
// Git disallows any filenames to have a .git directory in them.
|
||||
for part := range strings.SplitSeq(name, "/") {
|
||||
if strings.ToLower(part) == ".git" {
|
||||
if strings.EqualFold(part, ".git") {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user