mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-20 14:48:30 +02:00
Backport #35036 by @lunny Fix #35030 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
ec0c418719
commit
0b31272c7e
@ -7,6 +7,7 @@ been added to each release, please refer to the [blog](https://blog.gitea.com).
|
||||
## [1.24.3](https://github.com/go-gitea/gitea/releases/tag/1.24.3) - 2025-07-11
|
||||
|
||||
* BUGFIXES
|
||||
* Fix updating user visibility (#35036) (#35044)
|
||||
* Support base64-encoded agit push options (#35037) (#35041)
|
||||
* Make submodule link work with relative path (#35034) (#35038)
|
||||
* Fix bug when displaying git user avatar in commits list (#35006)
|
||||
|
@ -22,6 +22,13 @@ func FromPtr[T any](v *T) Option[T] {
|
||||
return Some(*v)
|
||||
}
|
||||
|
||||
func FromMapLookup[K comparable, V any](m map[K]V, k K) Option[V] {
|
||||
if v, ok := m[k]; ok {
|
||||
return Some(v)
|
||||
}
|
||||
return None[V]()
|
||||
}
|
||||
|
||||
func FromNonDefault[T comparable](v T) Option[T] {
|
||||
var zero T
|
||||
if v == zero {
|
||||
|
@ -56,6 +56,12 @@ func TestOption(t *testing.T) {
|
||||
opt3 := optional.FromNonDefault(1)
|
||||
assert.True(t, opt3.Has())
|
||||
assert.Equal(t, int(1), opt3.Value())
|
||||
|
||||
opt4 := optional.FromMapLookup(map[string]int{"a": 1}, "a")
|
||||
assert.True(t, opt4.Has())
|
||||
assert.Equal(t, 1, opt4.Value())
|
||||
opt4 = optional.FromMapLookup(map[string]int{"a": 1}, "b")
|
||||
assert.False(t, opt4.Has())
|
||||
}
|
||||
|
||||
func Test_ParseBool(t *testing.T) {
|
||||
|
@ -240,7 +240,7 @@ func EditUser(ctx *context.APIContext) {
|
||||
Description: optional.FromPtr(form.Description),
|
||||
IsActive: optional.FromPtr(form.Active),
|
||||
IsAdmin: user_service.UpdateOptionFieldFromPtr(form.Admin),
|
||||
Visibility: optional.FromNonDefault(api.VisibilityModes[form.Visibility]),
|
||||
Visibility: optional.FromMapLookup(api.VisibilityModes, form.Visibility),
|
||||
AllowGitHook: optional.FromPtr(form.AllowGitHook),
|
||||
AllowImportLocal: optional.FromPtr(form.AllowImportLocal),
|
||||
MaxRepoCreation: optional.FromPtr(form.MaxRepoCreation),
|
||||
|
@ -393,7 +393,7 @@ func Edit(ctx *context.APIContext) {
|
||||
Description: optional.Some(form.Description),
|
||||
Website: optional.Some(form.Website),
|
||||
Location: optional.Some(form.Location),
|
||||
Visibility: optional.FromNonDefault(api.VisibilityModes[form.Visibility]),
|
||||
Visibility: optional.FromMapLookup(api.VisibilityModes, form.Visibility),
|
||||
RepoAdminChangeTeamAccess: optional.FromPtr(form.RepoAdminChangeTeamAccess),
|
||||
}
|
||||
if err := user_service.UpdateUser(ctx, ctx.Org.Organization.AsUser(), opts); err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user