Skip to content

Commit 23c3c7a

Browse files
authored
Merge branch 'main' into external-issue-references-in-merge-messages
2 parents 975fde9 + e22ee46 commit 23c3c7a

40 files changed

+610
-1577
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ node-check:
219219

220220
.PHONY: clean-all
221221
clean-all: clean
222-
rm -rf $(WEBPACK_DEST_ENTRIES)
222+
rm -rf $(WEBPACK_DEST_ENTRIES) node_modules
223223

224224
.PHONY: clean
225225
clean:

integrations/api_repo_edit_test.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,14 @@ func getNewRepoEditOption(opts *api.EditRepoOption) *api.EditRepoOption {
130130

131131
func TestAPIRepoEdit(t *testing.T) {
132132
onGiteaRun(t, func(t *testing.T, u *url.URL) {
133+
bFalse, bTrue := false, true
134+
133135
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) // owner of the repo1 & repo16
134136
user3 := models.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User) // owner of the repo3, is an org
135137
user4 := models.AssertExistsAndLoadBean(t, &models.User{ID: 4}).(*models.User) // owner of neither repos
136138
repo1 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) // public repo
137139
repo3 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository) // public repo
140+
repo15 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 15}).(*models.Repository) // empty repo
138141
repo16 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 16}).(*models.Repository) // private repo
139142

140143
// Get user2's token
@@ -286,21 +289,33 @@ func TestAPIRepoEdit(t *testing.T) {
286289
// Test making a repo public that is private
287290
repo16 = models.AssertExistsAndLoadBean(t, &models.Repository{ID: 16}).(*models.Repository)
288291
assert.True(t, repo16.IsPrivate)
289-
private := false
290292
repoEditOption = &api.EditRepoOption{
291-
Private: &private,
293+
Private: &bFalse,
292294
}
293295
url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, repo16.Name, token2)
294296
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
295297
_ = session.MakeRequest(t, req, http.StatusOK)
296298
repo16 = models.AssertExistsAndLoadBean(t, &models.Repository{ID: 16}).(*models.Repository)
297299
assert.False(t, repo16.IsPrivate)
298300
// Make it private again
299-
private = true
300-
repoEditOption.Private = &private
301+
repoEditOption.Private = &bTrue
301302
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
302303
_ = session.MakeRequest(t, req, http.StatusOK)
303304

305+
// Test to change empty repo
306+
assert.False(t, repo15.IsArchived)
307+
url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, repo15.Name, token2)
308+
req = NewRequestWithJSON(t, "PATCH", url, &api.EditRepoOption{
309+
Archived: &bTrue,
310+
})
311+
_ = session.MakeRequest(t, req, http.StatusOK)
312+
repo15 = models.AssertExistsAndLoadBean(t, &models.Repository{ID: 15}).(*models.Repository)
313+
assert.True(t, repo15.IsArchived)
314+
req = NewRequestWithJSON(t, "PATCH", url, &api.EditRepoOption{
315+
Archived: &bFalse,
316+
})
317+
_ = session.MakeRequest(t, req, http.StatusOK)
318+
304319
// Test using org repo "user3/repo3" where user2 is a collaborator
305320
origRepoEditOption = getRepoEditOptionFromRepo(repo3)
306321
repoEditOption = getNewRepoEditOption(origRepoEditOption)

integrations/compare_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package integrations
6+
7+
import (
8+
"net/http"
9+
"testing"
10+
11+
"github.com/stretchr/testify/assert"
12+
)
13+
14+
func TestCompareTag(t *testing.T) {
15+
defer prepareTestEnv(t)()
16+
17+
session := loginUser(t, "user2")
18+
req := NewRequest(t, "GET", "/user2/repo1/compare/v1.1...master")
19+
resp := session.MakeRequest(t, req, http.StatusOK)
20+
htmlDoc := NewHTMLParser(t, resp.Body)
21+
selection := htmlDoc.doc.Find(".choose.branch .filter.dropdown")
22+
// A dropdown for both base and head.
23+
assert.Lenf(t, selection.Nodes, 2, "The template has changed")
24+
}

modules/queue/queue_bytefifo.go

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -114,43 +114,73 @@ func (q *ByteFIFOQueue) Run(atShutdown, atTerminate func(context.Context, func()
114114
}
115115

116116
func (q *ByteFIFOQueue) readToChan() {
117+
// handle quick cancels
118+
select {
119+
case <-q.closed:
120+
// tell the pool to shutdown.
121+
q.cancel()
122+
return
123+
default:
124+
}
125+
126+
backOffTime := time.Millisecond * 100
127+
maxBackOffTime := time.Second * 3
117128
for {
118-
select {
119-
case <-q.closed:
120-
// tell the pool to shutdown.
121-
q.cancel()
122-
return
123-
default:
124-
q.lock.Lock()
125-
bs, err := q.byteFIFO.Pop()
126-
if err != nil {
127-
q.lock.Unlock()
128-
log.Error("%s: %s Error on Pop: %v", q.typ, q.name, err)
129-
time.Sleep(time.Millisecond * 100)
130-
continue
131-
}
129+
success, resetBackoff := q.doPop()
130+
if resetBackoff {
131+
backOffTime = 100 * time.Millisecond
132+
}
132133

133-
if len(bs) == 0 {
134-
q.lock.Unlock()
135-
time.Sleep(time.Millisecond * 100)
136-
continue
134+
if success {
135+
select {
136+
case <-q.closed:
137+
// tell the pool to shutdown.
138+
q.cancel()
139+
return
140+
default:
137141
}
138-
139-
data, err := unmarshalAs(bs, q.exemplar)
140-
if err != nil {
141-
log.Error("%s: %s Failed to unmarshal with error: %v", q.typ, q.name, err)
142-
q.lock.Unlock()
143-
time.Sleep(time.Millisecond * 100)
144-
continue
142+
} else {
143+
select {
144+
case <-q.closed:
145+
// tell the pool to shutdown.
146+
q.cancel()
147+
return
148+
case <-time.After(backOffTime):
149+
}
150+
backOffTime += backOffTime / 2
151+
if backOffTime > maxBackOffTime {
152+
backOffTime = maxBackOffTime
145153
}
146-
147-
log.Trace("%s %s: Task found: %#v", q.typ, q.name, data)
148-
q.WorkerPool.Push(data)
149-
q.lock.Unlock()
150154
}
151155
}
152156
}
153157

158+
func (q *ByteFIFOQueue) doPop() (success, resetBackoff bool) {
159+
q.lock.Lock()
160+
defer q.lock.Unlock()
161+
bs, err := q.byteFIFO.Pop()
162+
if err != nil {
163+
log.Error("%s: %s Error on Pop: %v", q.typ, q.name, err)
164+
return
165+
}
166+
if len(bs) == 0 {
167+
return
168+
}
169+
170+
resetBackoff = true
171+
172+
data, err := unmarshalAs(bs, q.exemplar)
173+
if err != nil {
174+
log.Error("%s: %s Failed to unmarshal with error: %v", q.typ, q.name, err)
175+
return
176+
}
177+
178+
log.Trace("%s %s: Task found: %#v", q.typ, q.name, data)
179+
q.WorkerPool.Push(data)
180+
success = true
181+
return
182+
}
183+
154184
// Shutdown processing from this queue
155185
func (q *ByteFIFOQueue) Shutdown() {
156186
log.Trace("%s: %s Shutting down", q.typ, q.name)

modules/templates/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func NewFuncMap() []template.FuncMap {
6060
"AppSubUrl": func() string {
6161
return setting.AppSubURL
6262
},
63-
"StaticUrlPrefix": func() string {
63+
"AssetUrlPrefix": func() string {
6464
return setting.StaticURLPrefix + "/assets"
6565
},
6666
"AppUrl": func() string {

options/locale/locale_en-US.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,9 @@ issues.review.resolved_by = marked this conversation as resolved
12861286
issues.assignee.error = Not all assignees was added due to an unexpected error.
12871287
issues.reference_issue.body = Body
12881288

1289+
compare.compare_base = base
1290+
compare.compare_head = compare
1291+
12891292
pulls.desc = Enable pull requests and code reviews.
12901293
pulls.new = New Pull Request
12911294
pulls.compare_changes = New Pull Request

0 commit comments

Comments
 (0)