Skip to content

Commit bd92cd6

Browse files
authored
Merge branch 'main' into sync-git-hook
2 parents c8faf20 + 3397fee commit bd92cd6

File tree

16 files changed

+89
-48
lines changed

16 files changed

+89
-48
lines changed

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,30 +279,30 @@ swagger-validate:
279279
.PHONY: errcheck
280280
errcheck:
281281
@hash errcheck > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
282-
GO111MODULE=off $(GO) get -u github.com/kisielk/errcheck; \
282+
$(GO) install github.com/kisielk/errcheck@8ddee489636a8311a376fc92e27a6a13c6658344; \
283283
fi
284284
@echo "Running errcheck..."
285285
@errcheck $(GO_PACKAGES)
286286

287287
.PHONY: revive
288288
revive:
289289
@hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
290-
GO111MODULE=off $(GO) get -u github.com/mgechev/revive; \
290+
$(GO) install github.com/mgechev/revive@v1.1.2; \
291291
fi
292292
@revive -config .revive.toml -exclude=./vendor/... ./...
293293

294294
.PHONY: misspell-check
295295
misspell-check:
296296
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
297-
GO111MODULE=off $(GO) get -u github.com/client9/misspell/cmd/misspell; \
297+
$(GO) install github.com/client9/misspell/cmd/misspell@v0.3.4; \
298298
fi
299299
@echo "Running misspell-check..."
300300
@misspell -error -i unknwon $(GO_SOURCES_OWN)
301301

302302
.PHONY: misspell
303303
misspell:
304304
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
305-
GO111MODULE=off $(GO) get -u github.com/client9/misspell/cmd/misspell; \
305+
$(GO) install github.com/client9/misspell/cmd/misspell@v0.3.4; \
306306
fi
307307
@echo "Running go misspell..."
308308
@misspell -w -i unknwon $(GO_SOURCES_OWN)
@@ -350,7 +350,7 @@ watch-frontend: node-check node_modules
350350
.PHONY: watch-backend
351351
watch-backend: go-check
352352
@hash air > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
353-
GO111MODULE=off $(GO) get -u github.com/cosmtrek/air; \
353+
$(GO) install github.com/cosmtrek/air@bedc18201271882c2be66d216d0e1a275b526ec4; \
354354
fi
355355
air -c .air.conf
356356

@@ -661,7 +661,7 @@ release-check: | $(DIST_DIRS)
661661
.PHONY: release-compress
662662
release-compress: | $(DIST_DIRS)
663663
@hash gxz > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
664-
GO111MODULE=off $(GO) get -u github.com/ulikunitz/xz/cmd/gxz; \
664+
$(GO) install github.com/ulikunitz/xz/cmd/gxz@v0.5.10; \
665665
fi
666666
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
667667

integrations/api_nodeinfo_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
"net/url"
10+
"testing"
11+
12+
"code.gitea.io/gitea/modules/setting"
13+
api "code.gitea.io/gitea/modules/structs"
14+
15+
"github.com/stretchr/testify/assert"
16+
)
17+
18+
func TestNodeinfo(t *testing.T) {
19+
onGiteaRun(t, func(*testing.T, *url.URL) {
20+
setting.Federation.Enabled = true
21+
defer func() {
22+
setting.Federation.Enabled = false
23+
}()
24+
25+
req := NewRequestf(t, "GET", "/api/v1/nodeinfo")
26+
resp := MakeRequest(t, req, http.StatusOK)
27+
var nodeinfo api.NodeInfo
28+
DecodeJSON(t, resp, &nodeinfo)
29+
assert.Equal(t, "gitea", nodeinfo.Software.Name)
30+
})
31+
}

models/session.go renamed to models/login/session.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5-
package models
5+
package login
66

77
import (
88
"fmt"

modules/git/submodule.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ func getRefURL(refURL, urlPrefix, repoFullName, sshDomain string) string {
5252
urlPrefixHostname = prefixURL.Host
5353
}
5454

55-
if strings.HasSuffix(urlPrefix, "/") {
56-
urlPrefix = urlPrefix[:len(urlPrefix)-1]
57-
}
55+
urlPrefix = strings.TrimSuffix(urlPrefix, "/")
5856

5957
// FIXME: Need to consider branch - which will require changes in modules/git/commit.go:GetSubModules
6058
// Relative url prefix check (according to git submodule documentation)

modules/gitgraph/graph_models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func newRefsFromRefNames(refNames []byte) []git.Reference {
220220
refName := string(refNameBytes)
221221
if strings.HasPrefix(refName, "tag: ") {
222222
refName = strings.TrimPrefix(refName, "tag: ")
223-
} else if strings.HasPrefix(refName, "HEAD -> ") {
223+
} else {
224224
refName = strings.TrimPrefix(refName, "HEAD -> ")
225225
}
226226
refs = append(refs, git.Reference{

modules/graceful/restart_unix.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ func RestartProcess() (int, error) {
5555
unixListener.SetUnlinkOnClose(false)
5656
}
5757
// Remember to close these at the end.
58-
defer files[i].Close()
58+
defer func(i int) {
59+
_ = files[i].Close()
60+
}(i)
5961
}
6062

6163
// Use the original binary location. This works with symlinks such that if

modules/indexer/stats/queue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func handle(data ...queue.Data) {
2727
}
2828

2929
func initStatsQueue() error {
30-
statsQueue = queue.CreateUniqueQueue("repo_stats_update", handle, int64(0)).(queue.UniqueQueue)
30+
statsQueue = queue.CreateUniqueQueue("repo_stats_update", handle, int64(0))
3131
if statsQueue == nil {
3232
return fmt.Errorf("Unable to create repo_stats_update Queue")
3333
}

modules/lfs/endpoint.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ func endpointFromCloneURL(rawurl string) *url.URL {
2929
return ep
3030
}
3131

32-
if strings.HasSuffix(ep.Path, "/") {
33-
ep.Path = ep.Path[:len(ep.Path)-1]
34-
}
32+
ep.Path = strings.TrimSuffix(ep.Path, "/")
3533

3634
if ep.Scheme == "file" {
3735
return ep

modules/markup/common/footnote.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ type Footnote struct {
125125
// Dump implements Node.Dump.
126126
func (n *Footnote) Dump(source []byte, level int) {
127127
m := map[string]string{}
128-
m["Index"] = fmt.Sprintf("%v", n.Index)
129-
m["Ref"] = fmt.Sprintf("%s", n.Ref)
130-
m["Name"] = fmt.Sprintf("%v", n.Name)
128+
m["Index"] = strconv.Itoa(n.Index)
129+
m["Ref"] = string(n.Ref)
130+
m["Name"] = string(n.Name)
131131
ast.DumpHelper(n, source, level, m, nil)
132132
}
133133

modules/session/db.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"log"
99
"sync"
1010

11-
"code.gitea.io/gitea/models"
11+
"code.gitea.io/gitea/models/login"
1212
"code.gitea.io/gitea/modules/timeutil"
1313

1414
"gitea.com/go-chi/session"
@@ -72,7 +72,7 @@ func (s *DBStore) Release() error {
7272
return err
7373
}
7474

75-
return models.UpdateSession(s.sid, data)
75+
return login.UpdateSession(s.sid, data)
7676
}
7777

7878
// Flush deletes all session data.
@@ -98,7 +98,7 @@ func (p *DBProvider) Init(maxLifetime int64, connStr string) error {
9898

9999
// Read returns raw session store by session ID.
100100
func (p *DBProvider) Read(sid string) (session.RawStore, error) {
101-
s, err := models.ReadSession(sid)
101+
s, err := login.ReadSession(sid)
102102
if err != nil {
103103
return nil, err
104104
}
@@ -118,7 +118,7 @@ func (p *DBProvider) Read(sid string) (session.RawStore, error) {
118118

119119
// Exist returns true if session with given ID exists.
120120
func (p *DBProvider) Exist(sid string) bool {
121-
has, err := models.ExistSession(sid)
121+
has, err := login.ExistSession(sid)
122122
if err != nil {
123123
panic("session/DB: error checking existence: " + err.Error())
124124
}
@@ -127,12 +127,12 @@ func (p *DBProvider) Exist(sid string) bool {
127127

128128
// Destroy deletes a session by session ID.
129129
func (p *DBProvider) Destroy(sid string) error {
130-
return models.DestroySession(sid)
130+
return login.DestroySession(sid)
131131
}
132132

133133
// Regenerate regenerates a session store from old session ID to new one.
134134
func (p *DBProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error) {
135-
s, err := models.RegenerateSession(oldsid, sid)
135+
s, err := login.RegenerateSession(oldsid, sid)
136136
if err != nil {
137137
return nil, err
138138

@@ -153,7 +153,7 @@ func (p *DBProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err err
153153

154154
// Count counts and returns number of sessions.
155155
func (p *DBProvider) Count() int {
156-
total, err := models.CountSessions()
156+
total, err := login.CountSessions()
157157
if err != nil {
158158
panic("session/DB: error counting records: " + err.Error())
159159
}
@@ -162,7 +162,7 @@ func (p *DBProvider) Count() int {
162162

163163
// GC calls GC to clean expired sessions.
164164
func (p *DBProvider) GC() {
165-
if err := models.CleanupSessions(p.maxLifetime); err != nil {
165+
if err := login.CleanupSessions(p.maxLifetime); err != nil {
166166
log.Printf("session/DB: error garbage collecting: %v", err)
167167
}
168168
}

options/locale/locale_pt-PT.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,6 +2763,7 @@ publish_release=`lançou <a href="%s/releases/tag/%s"> "%[4]s" </a> à <a href="
27632763
review_dismissed=`descartou a revisão de <b>%[4]s</b> para <a href="%[1]s/pulls/%[2]s">%[3]s#%[2]s</a>`
27642764
review_dismissed_reason=Motivo:
27652765
create_branch=criou o ramo <a href="%[1]s/src/branch/%[2]s">%[3]s</a> em <a href="%[1]s">%[4]s</a>
2766+
watched_repo=começou a vigiar <a href="%[1]s">%[2]s</a>
27662767

27672768
[tool]
27682769
ago=há %s

options/locale/locale_zh-TW.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ view_home=訪問 %s
228228
search_repos=搜尋儲存庫...
229229
filter=其他篩選條件
230230
filter_by_team_repositories=以團隊儲存庫篩選
231+
feed_of=「%s」的訊息來源
231232

232233
show_archived=已封存
233234
show_both_archived_unarchived=顯示已封存和未封存
@@ -887,6 +888,7 @@ migrate_items_releases=版本發佈
887888
migrate_repo=遷移儲存庫
888889
migrate.clone_address=從 URL 遷移 / Clone
889890
migrate.clone_address_desc=現有存儲庫的 HTTP(S) 或 Git Clone URL
891+
migrate.github_token_desc=由於 Github API 的速率限制,您可在此輸入一個或多個由半形逗號「,」分隔的 Token 來加快遷移速度。警告:濫用此功能可能會違反該服務提供者的政策並導致帳戶被封鎖。
890892
migrate.clone_local_path=或者是本地端伺服器路徑
891893
migrate.permission_denied=您並沒有導入本地儲存庫的權限。
892894
migrate.permission_denied_blocked=您未被允許從已封鎖的主機匯入。
@@ -2026,6 +2028,8 @@ diff.file_image_height=高度
20262028
diff.file_byte_size=大小
20272029
diff.file_suppressed=檔案差異因為檔案過大而無法顯示
20282030
diff.file_suppressed_line_too_long=檔案差異因為一行或多行太長而無法顯示
2031+
diff.too_many_files=本差異變更的檔案數量過多導致部分檔案未顯示
2032+
diff.show_more=顯示更多
20292033
diff.generated=generated
20302034
diff.vendored=vendored
20312035
diff.comment.placeholder=留言...
@@ -2774,6 +2778,8 @@ publish_release=`發佈了 <a href="%[1]s">%[3]s</a> 的<a href="%s/releases/tag
27742778
review_dismissed=`取消了 <b>%[4]s</b> 對 <a href="%[1]s/pulls/%[2]s">%[3]s#%[2]s</a> 的審核`
27752779
review_dismissed_reason=原因:
27762780
create_branch=建立了分支 <a href="%[1]s/src/branch/%[2]s">%[3]s</a> 於 <a href="%[1]s">%[4]s</a>
2781+
stared_repo=為 <a href="%[1]s">%[2]s</a> 加上星號
2782+
watched_repo=開始關注 <a href="%[1]s">%[2]s</a>
27772783

27782784
[tool]
27792785
ago=%s前

routers/web/repo/issue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,7 @@ func ViewIssue(ctx *context.Context) {
15431543
ctx.ServerError("LoadProtectedBranch", err)
15441544
return
15451545
}
1546+
ctx.Data["ShowMergeInstructions"] = true
15461547
if pull.ProtectedBranch != nil {
15471548
cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull)
15481549
ctx.Data["IsBlockedByApprovals"] = !pull.ProtectedBranch.HasEnoughApprovals(pull)
@@ -1554,6 +1555,7 @@ func ViewIssue(ctx *context.Context) {
15541555
ctx.Data["ChangedProtectedFiles"] = pull.ChangedProtectedFiles
15551556
ctx.Data["IsBlockedByChangedProtectedFiles"] = len(pull.ChangedProtectedFiles) != 0
15561557
ctx.Data["ChangedProtectedFilesNum"] = len(pull.ChangedProtectedFiles)
1558+
ctx.Data["ShowMergeInstructions"] = pull.ProtectedBranch.CanUserPush(ctx.User.ID)
15571559
}
15581560
ctx.Data["WillSign"] = false
15591561
if ctx.User != nil {

services/pull/check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func CheckPrsForBaseBranch(baseRepo *models.Repository, baseBranchName string) e
253253

254254
// Init runs the task queue to test all the checking status pull requests
255255
func Init() error {
256-
prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "").(queue.UniqueQueue)
256+
prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "")
257257

258258
if prQueue == nil {
259259
return fmt.Errorf("Unable to create pr_patch_checker Queue")

services/repository/push.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package repository
66

77
import (
8+
"errors"
89
"fmt"
910
"time"
1011

@@ -36,9 +37,9 @@ func handle(data ...queue.Data) {
3637
}
3738

3839
func initPushQueue() error {
39-
pushQueue = queue.CreateQueue("push_update", handle, []*repo_module.PushUpdateOptions{}).(queue.Queue)
40+
pushQueue = queue.CreateQueue("push_update", handle, []*repo_module.PushUpdateOptions{})
4041
if pushQueue == nil {
41-
return fmt.Errorf("Unable to create push_update Queue")
42+
return errors.New("unable to create push_update Queue")
4243
}
4344

4445
go graceful.GetManager().RunWithShutdownFns(pushQueue.Run)

templates/repo/issue/view_content/pull.tmpl

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -485,25 +485,27 @@
485485
{{end}}
486486
</div>
487487
</div>
488-
<div class="instruct-toggle ml-3"> {{$.i18n.Tr "repo.pulls.merge_instruction_hint" | Safe}} </div>
489-
<div class="instruct-content" style="display:none">
490-
<div class="ui divider"></div>
491-
<div><h3 class="di">{{$.i18n.Tr "step1"}} </h3>{{$.i18n.Tr "repo.pulls.merge_instruction_step1_desc"}}</div>
492-
<div class="ui secondary segment">
493-
{{if eq .Issue.PullRequest.Flow 0}}
494-
<div>git checkout -b {{if ne .Issue.PullRequest.HeadRepo.ID .Issue.PullRequest.BaseRepo.ID}}{{.Issue.PullRequest.HeadRepo.OwnerName}}-{{end}}{{.Issue.PullRequest.HeadBranch}} {{.Issue.PullRequest.BaseBranch}}</div>
495-
<div>git pull {{if ne .Issue.PullRequest.HeadRepo.ID .Issue.PullRequest.BaseRepo.ID}}{{.Issue.PullRequest.HeadRepo.HTMLURL}}{{else}}origin{{end}} {{.Issue.PullRequest.HeadBranch}}</div>
496-
{{else}}
497-
<div>git fetch origin {{.Issue.PullRequest.GetGitRefName}}:{{.Issue.PullRequest.HeadBranch}}</div>
498-
{{end}}
499-
</div>
500-
<div><h3 class="di">{{$.i18n.Tr "step2"}} </h3>{{$.i18n.Tr "repo.pulls.merge_instruction_step2_desc"}}</div>
501-
<div class="ui secondary segment">
502-
<div>git checkout {{.Issue.PullRequest.BaseBranch}}</div>
503-
<div>git merge --no-ff {{if ne .Issue.PullRequest.HeadRepo.ID .Issue.PullRequest.BaseRepo.ID}}{{.Issue.PullRequest.HeadRepo.OwnerName}}-{{end}}{{.Issue.PullRequest.HeadBranch}}</div>
504-
<div>git push origin {{.Issue.PullRequest.BaseBranch}}</div>
488+
{{if .ShowMergeInstructions}}
489+
<div class="instruct-toggle ml-3"> {{$.i18n.Tr "repo.pulls.merge_instruction_hint" | Safe}} </div>
490+
<div class="instruct-content" style="display:none">
491+
<div class="ui divider"></div>
492+
<div><h3 class="di">{{$.i18n.Tr "step1"}} </h3>{{$.i18n.Tr "repo.pulls.merge_instruction_step1_desc"}}</div>
493+
<div class="ui secondary segment">
494+
{{if eq .Issue.PullRequest.Flow 0}}
495+
<div>git checkout -b {{if ne .Issue.PullRequest.HeadRepo.ID .Issue.PullRequest.BaseRepo.ID}}{{.Issue.PullRequest.HeadRepo.OwnerName}}-{{end}}{{.Issue.PullRequest.HeadBranch}} {{.Issue.PullRequest.BaseBranch}}</div>
496+
<div>git pull {{if ne .Issue.PullRequest.HeadRepo.ID .Issue.PullRequest.BaseRepo.ID}}{{.Issue.PullRequest.HeadRepo.HTMLURL}}{{else}}origin{{end}} {{.Issue.PullRequest.HeadBranch}}</div>
497+
{{else}}
498+
<div>git fetch origin {{.Issue.PullRequest.GetGitRefName}}:{{.Issue.PullRequest.HeadBranch}}</div>
499+
{{end}}
500+
</div>
501+
<div><h3 class="di">{{$.i18n.Tr "step2"}} </h3>{{$.i18n.Tr "repo.pulls.merge_instruction_step2_desc"}}</div>
502+
<div class="ui secondary segment">
503+
<div>git checkout {{.Issue.PullRequest.BaseBranch}}</div>
504+
<div>git merge --no-ff {{if ne .Issue.PullRequest.HeadRepo.ID .Issue.PullRequest.BaseRepo.ID}}{{.Issue.PullRequest.HeadRepo.OwnerName}}-{{end}}{{.Issue.PullRequest.HeadBranch}}</div>
505+
<div>git push origin {{.Issue.PullRequest.BaseBranch}}</div>
506+
</div>
505507
</div>
506-
</div>
508+
{{end}}
507509
{{else}}
508510
<div class="ui divider"></div>
509511
<div class="item text red">

0 commit comments

Comments
 (0)