Skip to content

Commit 686bb1b

Browse files
committed
Updating to latest Gitea 1.16
2 parents b0c45fe + c077a03 commit 686bb1b

File tree

9 files changed

+181
-49
lines changed

9 files changed

+181
-49
lines changed

CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,54 @@ This changelog goes through all the changes that have been made in each release
44
without substantial changes to our git log; to see the highlights of what has
55
been added to each release, please refer to the [blog](https://blog.gitea.io).
66

7+
## [1.16.2](https://github.com/go-gitea/gitea/releases/tag/v1.16.2) - 2022-02-24
8+
9+
* ENHANCEMENTS
10+
* Show fullname on issue edits and gpg/ssh signing info (#18828)
11+
* Immediately Hammer if second kill is sent (#18823) (#18826)
12+
* Allow mermaid render error to wrap (#18791)
13+
* BUGFIXES
14+
* Fix ldap user sync missed email in email_address table (#18786) (#18876)
15+
* Update assignees check to include any writing team and change org sidebar (#18680) (#18873)
16+
* Don't report signal: killed errors in serviceRPC (#18850) (#18865)
17+
* Fix bug where certain LDAP settings were reverted (#18859)
18+
* Update go-org to 1.6.0 (#18824) (#18839)
19+
* Fix login with email for ldap users (#18800) (#18836)
20+
* Fix bug for get user by email (#18834)
21+
* Fix panic in EscapeReader (#18820) (#18821)
22+
* Fix ldap loginname (#18789) (#18804)
23+
* Remove redundant call to UpdateRepoStats during migration (#18591) (#18794)
24+
* In disk_channel queues synchronously push to disk on shutdown (#18415) (#18788)
25+
* Fix template bug of LFS lock (#18784) (#18787)
26+
* Attempt to fix the webauthn migration again - part 3 (#18770) (#18771)
27+
* Send mail to issue/pr assignee/reviewer also when OnMention is set (#18707) (#18765)
28+
* Fix a broken link in commits_list_small.tmpl (#18763) (#18764)
29+
* Increase the size of the webauthn_credential credential_id field (#18739) (#18756)
30+
* Prevent dangling GetAttribute calls (#18754) (#18755)
31+
* Fix isempty detection of git repository (#18746) (#18750)
32+
* Fix source code line highlighting on external tracker (#18729) (#18740)
33+
* Prevent double encoding of branch names in delete branch (#18714) (#18738)
34+
* Always set PullRequestWorkInProgressPrefixes in PrepareViewPullInfo (#18713) (#18737)
35+
* Fix forked repositories missed tags (#18719) (#18735)
36+
* Fix release typo (#18728) (#18731)
37+
* Separate the details links of commit-statuses in headers (#18661) (#18730)
38+
* Update object repo with the migrated repository (#18684) (#18726)
39+
* Fix bug for version update hint (#18701) (#18705)
40+
* Fix issue with docker-rootless shimming script (#18690) (#18699)
41+
* Let `MinUnitAccessMode` return correct perm (#18675) (#18689)
42+
* Prevent security failure due to bad APP_ID (#18678) (#18682)
43+
* Restart zero worker if there is still work to do (#18658) (#18672)
44+
* If rendering has failed due to a net.OpError stop rendering (#18642) (#18645)
45+
* TESTING
46+
* Ensure git tag tests and others create test repos in tmpdir (#18447) (#18767)
47+
* BUILD
48+
* Reduce CI go module downloads, add make targets (#18708, #18475, #18443) (#18741)
49+
* MISC
50+
* Put buttons back in org dashboard (#18817) (#18825)
51+
* Various Mermaid improvements (#18776) (#18780)
52+
* C preprocessor colors improvement (#18671) (#18696)
53+
* Fix the missing i18n key for update checker (#18646) (#18665)
54+
755
## [1.16.1](https://github.com/go-gitea/gitea/releases/tag/v1.16.1) - 2022-02-06
856

957
* SECURITY

models/migrations/v210.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,23 @@ func remigrateU2FCredentials(x *xorm.Engine) error {
137137
CreatedUnix: reg.CreatedUnix,
138138
}
139139

140-
has, err := sess.ID(reg.ID).Where("id = ?", reg.ID).Get(new(webauthnCredential))
140+
has, err := sess.ID(reg.ID).Get(new(webauthnCredential))
141141
if err != nil {
142142
return fmt.Errorf("unable to get webauthn_credential[%d]. Error: %w", reg.ID, err)
143143
}
144144
if !has {
145-
_, err = sess.Insert(remigrated)
145+
has, err := sess.Where("`lower_name`=?", remigrated.LowerName).And("`user_id`=?", remigrated.UserID).Exist(new(webauthnCredential))
146146
if err != nil {
147-
return fmt.Errorf("unable to (re)insert webauthn_credential[%d]. Error: %w", reg.ID, err)
147+
return fmt.Errorf("unable to check webauthn_credential[lower_name: %s, user_id:%v]. Error: %w", remigrated.LowerName, remigrated.UserID, err)
148148
}
149+
if !has {
150+
_, err = sess.Insert(remigrated)
151+
if err != nil {
152+
return fmt.Errorf("unable to (re)insert webauthn_credential[%d]. Error: %w", reg.ID, err)
153+
}
149154

150-
continue
155+
continue
156+
}
151157
}
152158

153159
_, err = sess.ID(remigrated.ID).AllCols().Update(remigrated)

models/repo.go

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,27 +150,56 @@ func getRepoAssignees(ctx context.Context, repo *repo_model.Repository) (_ []*us
150150
}
151151

152152
e := db.GetEngine(ctx)
153-
accesses := make([]*Access, 0, 10)
154-
if err = e.
153+
userIDs := make([]int64, 0, 10)
154+
if err = e.Table("access").
155155
Where("repo_id = ? AND mode >= ?", repo.ID, perm.AccessModeWrite).
156-
Find(&accesses); err != nil {
156+
Select("id").
157+
Find(&userIDs); err != nil {
157158
return nil, err
158159
}
159160

160-
// Leave a seat for owner itself to append later, but if owner is an organization
161-
// and just waste 1 unit is cheaper than re-allocate memory once.
162-
users := make([]*user_model.User, 0, len(accesses)+1)
163-
if len(accesses) > 0 {
164-
userIDs := make([]int64, len(accesses))
165-
for i := 0; i < len(accesses); i++ {
166-
userIDs[i] = accesses[i].UserID
161+
additionalUserIDs := make([]int64, 0, 10)
162+
if err = e.Table("team_user").
163+
Join("INNER", "team_repo", "`team_repo`.team_id = `team_user`.team_id").
164+
Join("INNER", "team_unit", "`team_unit`.team_id = `team_user`.team_id").
165+
Where("`team_repo`.repo_id = ? AND `team_unit`.access_mode >= ?", repo.ID, perm.AccessModeWrite).
166+
Distinct("`team_user`.uid").
167+
Select("`team_user`.uid").
168+
Find(&additionalUserIDs); err != nil {
169+
return nil, err
170+
}
171+
172+
uidMap := map[int64]bool{}
173+
i := 0
174+
for _, uid := range userIDs {
175+
if uidMap[uid] {
176+
continue
177+
}
178+
uidMap[uid] = true
179+
userIDs[i] = uid
180+
i++
181+
}
182+
userIDs = userIDs[:i]
183+
userIDs = append(userIDs, additionalUserIDs...)
184+
185+
for _, uid := range additionalUserIDs {
186+
if uidMap[uid] {
187+
continue
167188
}
189+
userIDs[i] = uid
190+
i++
191+
}
192+
userIDs = userIDs[:i]
168193

194+
// Leave a seat for owner itself to append later, but if owner is an organization
195+
// and just waste 1 unit is cheaper than re-allocate memory once.
196+
users := make([]*user_model.User, 0, len(userIDs)+1)
197+
if len(userIDs) > 0 {
169198
if err = e.In("id", userIDs).Find(&users); err != nil {
170199
return nil, err
171200
}
172201
}
173-
if !repo.Owner.IsOrganization() {
202+
if !repo.Owner.IsOrganization() && !uidMap[repo.OwnerID] {
174203
users = append(users, repo.Owner)
175204
}
176205

models/user/user.go

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,9 @@ func validateUser(u *User) error {
852852
return ValidateEmail(u.Email)
853853
}
854854

855-
func updateUser(ctx context.Context, u *User, changePrimaryEmail bool) error {
856-
if err := validateUser(u); err != nil {
855+
func updateUser(ctx context.Context, u *User, changePrimaryEmail bool, cols ...string) error {
856+
err := validateUser(u)
857+
if err != nil {
857858
return err
858859
}
859860

@@ -885,15 +886,35 @@ func updateUser(ctx context.Context, u *User, changePrimaryEmail bool) error {
885886
}); err != nil {
886887
return err
887888
}
889+
} else { // check if primary email in email_address table
890+
primaryEmailExist, err := e.Where("uid=? AND is_primary=?", u.ID, true).Exist(&EmailAddress{})
891+
if err != nil {
892+
return err
893+
}
894+
895+
if !primaryEmailExist {
896+
if _, err = e.Insert(&EmailAddress{
897+
Email: u.Email,
898+
UID: u.ID,
899+
IsActivated: true,
900+
IsPrimary: true,
901+
}); err != nil {
902+
return err
903+
}
904+
}
888905
}
889906

890-
_, err := e.ID(u.ID).AllCols().Update(u)
907+
if len(cols) == 0 {
908+
_, err = e.ID(u.ID).AllCols().Update(u)
909+
} else {
910+
_, err = e.ID(u.ID).Cols(cols...).Update(u)
911+
}
891912
return err
892913
}
893914

894915
// UpdateUser updates user's information.
895-
func UpdateUser(u *User, emailChanged bool) error {
896-
return updateUser(db.DefaultContext, u, emailChanged)
916+
func UpdateUser(u *User, emailChanged bool, cols ...string) error {
917+
return updateUser(db.DefaultContext, u, emailChanged, cols...)
897918
}
898919

899920
// UpdateUserCols update user according special columns

routers/web/org/teams.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ func TeamMembers(ctx *context.Context) {
311311
ctx.ServerError("GetMembers", err)
312312
return
313313
}
314+
ctx.Data["Units"] = unit_model.Units
314315
ctx.HTML(http.StatusOK, tplTeamMembers)
315316
}
316317

@@ -323,6 +324,7 @@ func TeamRepositories(ctx *context.Context) {
323324
ctx.ServerError("GetRepositories", err)
324325
return
325326
}
327+
ctx.Data["Units"] = unit_model.Units
326328
ctx.HTML(http.StatusOK, tplTeamRepositories)
327329
}
328330

routers/web/repo/compare.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func setPathsCompareContext(ctx *context.Context, base, head *git.Commit, headOw
7777
ctx.Data["SourcePath"] = SourceCommitURL(headOwner, headName, head)
7878
ctx.Data["RawPath"] = RawCommitURL(headOwner, headName, head)
7979
if base != nil {
80-
ctx.Data["BeforeSourcePath"] = SourceCommitURL(headOwner, headName, head)
81-
ctx.Data["BeforeRawPath"] = RawCommitURL(headOwner, headName, head)
80+
ctx.Data["BeforeSourcePath"] = SourceCommitURL(headOwner, headName, base)
81+
ctx.Data["BeforeRawPath"] = RawCommitURL(headOwner, headName, base)
8282
}
8383
}
8484

routers/web/repo/http.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
103103
}
104104

105105
isWiki := false
106-
var unitType = unit.TypeCode
106+
unitType := unit.TypeCode
107107
var wikiRepoName string
108108
if strings.HasSuffix(reponame, ".wiki") {
109109
isWiki = true
@@ -456,7 +456,6 @@ func serviceRPC(h serviceHandler, service string) {
456456
if err := h.r.Body.Close(); err != nil {
457457
log.Error("serviceRPC: Close: %v", err)
458458
}
459-
460459
}()
461460

462461
if !hasAccess(service, h, true) {
@@ -467,7 +466,7 @@ func serviceRPC(h serviceHandler, service string) {
467466
h.w.Header().Set("Content-Type", fmt.Sprintf("application/x-git-%s-result", service))
468467

469468
var err error
470-
var reqBody = h.r.Body
469+
reqBody := h.r.Body
471470

472471
// Handle GZIP.
473472
if h.r.Header.Get("Content-Encoding") == "gzip" {
@@ -502,7 +501,9 @@ func serviceRPC(h serviceHandler, service string) {
502501
cmd.Stderr = &stderr
503502

504503
if err := cmd.Run(); err != nil {
505-
log.Error("Fail to serve RPC(%s) in %s: %v - %s", service, h.dir, err, stderr.String())
504+
if err.Error() != "signal: killed" {
505+
log.Error("Fail to serve RPC(%s) in %s: %v - %s", service, h.dir, err, stderr.String())
506+
}
506507
return
507508
}
508509
}

services/auth/source/ldap/source_sync.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func (source *Source) Sync(ctx context.Context, updateExisting bool) error {
143143
log.Trace("SyncExternalUsers[%s]: Updating user %s", source.authSource.Name, usr.Name)
144144

145145
usr.FullName = fullName
146+
emailChanged := usr.Email != su.Mail
146147
usr.Email = su.Mail
147148
// Change existing admin flag only if AdminFilter option is set
148149
if len(source.AdminFilter) > 0 {
@@ -154,7 +155,7 @@ func (source *Source) Sync(ctx context.Context, updateExisting bool) error {
154155
}
155156
usr.IsActive = true
156157

157-
err = user_model.UpdateUserCols(db.DefaultContext, usr, "full_name", "email", "is_admin", "is_restricted", "is_active")
158+
err = user_model.UpdateUser(usr, emailChanged, "full_name", "email", "is_admin", "is_restricted", "is_active")
158159
if err != nil {
159160
log.Error("SyncExternalUsers[%s]: Error updating user %s: %v", source.authSource.Name, usr.Name, err)
160161
}

templates/org/team/sidebar.tmpl

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,55 @@
2525
<span class="text grey italic">{{.i18n.Tr "org.teams.no_desc"}}</span>
2626
{{end}}
2727
</div>
28-
29-
<div class="item">
30-
{{if eq .Team.LowerName "owners"}}
28+
{{if eq .Team.LowerName "owners"}}
29+
<div class="item">
3130
{{.i18n.Tr "org.teams.owners_permission_desc" | Str2html}}
32-
{{else if (eq .Team.AccessMode 1)}}
33-
{{if .Team.IncludesAllRepositories}}
34-
{{.i18n.Tr "org.teams.all_repositories_read_permission_desc" | Str2html}}
35-
{{else}}
36-
{{.i18n.Tr "org.teams.read_permission_desc" | Str2html}}
37-
{{end}}
38-
{{else if (eq .Team.AccessMode 2)}}
39-
{{if .Team.IncludesAllRepositories}}
40-
{{.i18n.Tr "org.teams.all_repositories_write_permission_desc" | Str2html}}
31+
</div>
32+
{{else}}
33+
<div class="item">
34+
<h3>{{.i18n.Tr "org.team_access_desc"}}</h3>
35+
<ul>
36+
{{if .Team.IncludesAllRepositories}}
37+
<li>{{.i18n.Tr "org.teams.all_repositories" | Str2html}}
38+
{{else}}
39+
<li>{{.i18n.Tr "org.teams.specific_repositories" | Str2html}}
40+
{{end}}
41+
{{if .Team.CanCreateOrgRepo}}
42+
<li>{{.i18n.Tr "org.teams.can_create_org_repo"}}
43+
{{end}}
44+
</ul>
45+
{{if (eq .Team.AccessMode 2)}}
46+
<h3>{{.i18n.Tr "org.settings.permission"}}</h3>
47+
{{.i18n.Tr "org.teams.write_permission_desc"}}
48+
{{else if (eq .Team.AccessMode 3)}}
49+
<h3>{{.i18n.Tr "org.settings.permission"}}</h3>
50+
{{.i18n.Tr "org.teams.admin_permission_desc"}}
4151
{{else}}
42-
{{.i18n.Tr "org.teams.write_permission_desc" | Str2html}}
52+
<table class="ui table">
53+
<thead>
54+
<tr>
55+
<th>{{.i18n.Tr "units.unit"}}</th>
56+
<th>{{.i18n.Tr "org.team_permission_desc"}}</th>
57+
</tr>
58+
</thead>
59+
<tbody>
60+
{{range $t, $unit := $.Units}}
61+
{{if and (lt $unit.MaxPerm 2) (not $unit.Type.UnitGlobalDisabled)}}
62+
<tr>
63+
<td><strong>{{$.i18n.Tr $unit.NameKey}}</strong></td>
64+
<td>{{if eq ($.Team.UnitAccessMode $unit.Type) 0 -}}
65+
{{$.i18n.Tr "org.teams.none_access"}}
66+
{{- else if or (eq $.Team.ID 0) (eq ($.Team.UnitAccessMode $unit.Type) 1) -}}
67+
{{$.i18n.Tr "org.teams.read_access"}}
68+
{{- else if eq ($.Team.UnitAccessMode $unit.Type) 2 -}}
69+
{{$.i18n.Tr "org.teams.write_access"}}
70+
{{- end}}</td>
71+
</tr>
72+
{{end}}
73+
{{end}}
74+
</tbody>
75+
</table>
4376
{{end}}
44-
{{else if (eq .Team.AccessMode 3)}}
45-
{{if .Team.IncludesAllRepositories}}
46-
{{.i18n.Tr "org.teams.all_repositories_admin_permission_desc" | Str2html}}
47-
{{else}}
48-
{{.i18n.Tr "org.teams.admin_permission_desc" | Str2html}}
49-
{{end}}
50-
{{end}}
51-
{{if .Team.CanCreateOrgRepo}}
52-
<br><br>{{.i18n.Tr "org.teams.create_repo_permission_desc" | Str2html}}
5377
{{end}}
5478
</div>
5579
</div>

0 commit comments

Comments
 (0)