Skip to content

Commit 8c943e0

Browse files
authored
Merge branch 'master' into assets_dir
2 parents 23fbe1b + 75dfc46 commit 8c943e0

File tree

291 files changed

+6526
-6277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+6526
-6277
lines changed

.drone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ steps:
495495
pull: always
496496
image: techknowlogick/xgo:go-1.16.x
497497
commands:
498-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt -y install nodejs
498+
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt -y install nodejs bsdtar\|libarchive-tools
499499
- export PATH=$PATH:$GOPATH/bin
500500
- make release
501501
environment:
@@ -591,7 +591,7 @@ steps:
591591
pull: always
592592
image: techknowlogick/xgo:go-1.16.x
593593
commands:
594-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt -y install nodejs
594+
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs bsdtar\|libarchive-tools
595595
- export PATH=$PATH:$GOPATH/bin
596596
- make release
597597
environment:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ coverage.all
8080
/public/css
8181
/public/fonts
8282
/public/img/webpack
83+
/web_src/fomantic/node_modules
84+
/web_src/fomantic/semantic.json
8385
/web_src/fomantic/build/*
8486
!/web_src/fomantic/build/semantic.js
8587
!/web_src/fomantic/build/semantic.css
@@ -93,6 +95,7 @@ coverage.all
9395
!/web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2
9496
/VERSION
9597
/.air
98+
/.npm-cache
9699

97100
# Snapcraft
98101
snap/.snapcraft/

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ audit=false
22
fund=false
33
package-lock=true
44
save-exact=true
5+
cache=.npm-cache

Makefile

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ else
1414

1515
# This is the "normal" part of the Makefile
1616

17+
TAR := $(shell hash bsdtar > /dev/null 2>&1 && echo "bsdtar --no-xattrs" || echo "tar" )
18+
1719
DIST := dist
1820
DIST_DIRS := $(DIST)/binaries $(DIST)/release
1921
IMPORT := code.gitea.io/gitea
@@ -93,7 +95,7 @@ GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/models/migrations code.gitea.io/
9395

9496
FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
9597
FOMANTIC_DEST := web_src/fomantic/build/semantic.js web_src/fomantic/build/semantic.css
96-
FOMANTIC_DEST_DIR := web_src/fomantic/build
98+
FOMANTIC_WORK_DIR := web_src/fomantic
9799

98100
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
99101
WEBPACK_CONFIGS := webpack.config.js
@@ -642,14 +644,16 @@ release-compress: | $(DIST_DIRS)
642644
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
643645

644646
.PHONY: release-sources
645-
release-sources: | $(DIST_DIRS) node_modules
647+
release-sources: | $(DIST_DIRS) npm-cache
646648
echo $(VERSION) > $(STORED_VERSION_FILE)
647-
tar --exclude=./$(DIST) --exclude=./.git --exclude=./$(MAKE_EVIDENCE_DIR) --exclude=./node_modules/.cache --exclude=./$(AIR_TMP_DIR) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
649+
$(eval EXCL := --exclude=$(shell [ ! "$(TAR)" = "tar" ] && echo "^" )./)
650+
$(eval EXCL_RECURSIVE := --exclude=)
651+
$(TAR) $(EXCL)$(DIST) $(EXCL).git $(EXCL)$(MAKE_EVIDENCE_DIR) $(EXCL_RECURSIVE)node_modules $(EXCL)$(AIR_TMP_DIR) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
648652
rm -f $(STORED_VERSION_FILE)
649653

650654
.PHONY: release-docs
651655
release-docs: | $(DIST_DIRS) docs
652-
tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
656+
$(TAR) -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
653657

654658
.PHONY: docs
655659
docs:
@@ -662,6 +666,25 @@ node_modules: package-lock.json
662666
npm install --no-save
663667
@touch node_modules
664668

669+
.PHONY: npm-cache
670+
npm-cache: .npm-cache $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui
671+
672+
.npm-cache: package-lock.json
673+
rm -rf .npm-cache
674+
$(eval ESBUILD_VERSION := $(shell node -p "require('./package-lock.json').dependencies.esbuild.version"))
675+
npm config --userconfig=.npmrc set cache=.npm-cache
676+
rm -rf node_modules && npm install --no-save
677+
npm config --userconfig=$(FOMANTIC_WORK_DIR)/.npmrc set cache=../../.npm-cache
678+
echo $(foreach build, darwin-64 $(foreach arch,arm arm64 32 64,linux-${arch}) $(foreach arch,32 64,windows-${arch}), esbuild-${build}@$(ESBUILD_VERSION)) | tr " " "\n" | xargs -n 1 -P 4 npm cache add
679+
rm -rf $(FOMANTIC_WORK_DIR)/node_modules
680+
@touch .npm-cache
681+
682+
.PHONY: npm-uncache
683+
npm-uncache:
684+
rm -rf .npm-cache
685+
npm config --userconfig=$(FOMANTIC_WORK_DIR)/.npmrc rm cache
686+
npm config --userconfig=.npmrc rm cache
687+
665688
.PHONY: npm-update
666689
npm-update: node-check | node_modules
667690
npx updates -cu
@@ -672,14 +695,22 @@ npm-update: node-check | node_modules
672695
.PHONY: fomantic
673696
fomantic: $(FOMANTIC_DEST)
674697

675-
$(FOMANTIC_DEST): $(FOMANTIC_CONFIGS) | node_modules
676-
@if [ ! -d node_modules/fomantic-ui ]; then \
677-
npm install --no-save --no-package-lock [email protected]; \
678-
fi
679-
rm -rf $(FOMANTIC_DEST_DIR)
680-
cp -f web_src/fomantic/theme.config.less node_modules/fomantic-ui/src/theme.config
681-
cp -rf web_src/fomantic/_site/* node_modules/fomantic-ui/src/_site/
682-
npx gulp -f node_modules/fomantic-ui/gulpfile.js build
698+
$(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui:
699+
ln -sf ../../semantic.json $(FOMANTIC_WORK_DIR)
700+
cd $(FOMANTIC_WORK_DIR); \
701+
rm -rf node_modules && mkdir node_modules && \
702+
npm install fomantic-ui; \
703+
rm -f semantic.json
704+
@touch $(FOMANTIC_WORK_DIR)/node_modules
705+
706+
$(FOMANTIC_DEST): $(FOMANTIC_CONFIGS) $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui
707+
ln -sf ../../semantic.json $(FOMANTIC_WORK_DIR)
708+
rm -rf $(FOMANTIC_WORK_DIR)/build
709+
cd $(FOMANTIC_WORK_DIR); \
710+
cp -f theme.config.less node_modules/fomantic-ui/src/theme.config; \
711+
cp -rf _site node_modules/fomantic-ui/src/; \
712+
npx gulp -f node_modules/fomantic-ui/gulpfile.js build; \
713+
rm -f semantic.json
683714
@touch $(FOMANTIC_DEST)
684715

685716
.PHONY: webpack

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ REVERSE_PROXY_AUTHENTICATION_USER = X-WEBAUTH-USER
555555
REVERSE_PROXY_AUTHENTICATION_EMAIL = X-WEBAUTH-EMAIL
556556
; Interpret X-Forwarded-For header or the X-Real-IP header and set this as the remote IP for the request
557557
REVERSE_PROXY_LIMIT = 1
558-
; List of IP addresses and networks seperated by comma of trusted proxy servers. Use `*` to trust all.
558+
; List of IP addresses and networks separated by comma of trusted proxy servers. Use `*` to trust all.
559559
REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.0/8,::1/128
560560
; The minimum password length for new Users
561561
MIN_PASSWORD_LENGTH = 6

go.mod

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ require (
8686
github.com/mgechev/revive v1.0.3
8787
github.com/mholt/acmez v0.1.3 // indirect
8888
github.com/mholt/archiver/v3 v3.5.0
89-
github.com/microcosm-cc/bluemonday v1.0.4
89+
github.com/microcosm-cc/bluemonday v1.0.6
9090
github.com/miekg/dns v1.1.40 // indirect
9191
github.com/minio/md5-simd v1.1.2 // indirect
9292
github.com/minio/minio-go/v7 v7.0.10
@@ -136,9 +136,9 @@ require (
136136
go.uber.org/multierr v1.6.0 // indirect
137137
go.uber.org/zap v1.16.0 // indirect
138138
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
139-
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
139+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
140140
golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93
141-
golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46
141+
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44
142142
golang.org/x/text v0.3.5
143143
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
144144
golang.org/x/tools v0.1.0
@@ -153,5 +153,3 @@ require (
153153
)
154154

155155
replace github.com/hashicorp/go-version => github.com/6543/go-version v1.2.4
156-
157-
replace github.com/microcosm-cc/bluemonday => github.com/lunny/bluemonday v1.0.5-0.20201227154428-ca34796141e8

go.sum

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+
196196
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
197197
github.com/chi-middleware/proxy v1.1.1 h1:4HaXUp8o2+bhHr1OhVy+VjN0+L7/07JDcn6v7YrTjrQ=
198198
github.com/chi-middleware/proxy v1.1.1/go.mod h1:jQwMEJct2tz9VmtCELxvnXoMfa+SOdikvbVJVHv/M+0=
199-
github.com/chris-ramon/douceur v0.2.0 h1:IDMEdxlEUUBYBKE4z/mJnFyVXox+MjuEVDJNN27glkU=
200-
github.com/chris-ramon/douceur v0.2.0/go.mod h1:wDW5xjJdeoMm1mRt4sD4c/LbF/mWdEpRXQKjTR8nIBE=
201199
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
202200
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
203201
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
@@ -776,8 +774,6 @@ github.com/libdns/libdns v0.2.0 h1:ewg3ByWrdUrxrje8ChPVMBNcotg7H9LQYg+u5De2RzI=
776774
github.com/libdns/libdns v0.2.0/go.mod h1:yQCXzk1lEZmmCPa857bnk4TsOiqYasqpyOEeSObbb40=
777775
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
778776
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
779-
github.com/lunny/bluemonday v1.0.5-0.20201227154428-ca34796141e8 h1:1omo92DLtxQu6VwVPSZAmduHaK5zssed6cvkHyl1XOg=
780-
github.com/lunny/bluemonday v1.0.5-0.20201227154428-ca34796141e8/go.mod h1:8iwZnFn2CDDNZ0r6UXhF4xawGvzaqzCRa1n3/lO3W2w=
781777
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96 h1:uNwtsDp7ci48vBTTxDuwcoTXz4lwtDTe7TjCQ0noaWY=
782778
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96/go.mod h1:mmIfjCSQlGYXmJ95jFN84AkQFnVABtKuJL8IrzwvUKQ=
783779
github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de/go.mod h1:3q8WtuPQsoRbatJuy3nvq/hRSvuBJrHHr+ybPPiNvHQ=
@@ -834,6 +830,8 @@ github.com/mholt/acmez v0.1.3 h1:J7MmNIk4Qf9b8mAGqAh4XkNeowv3f1zW816yf4zt7Qk=
834830
github.com/mholt/acmez v0.1.3/go.mod h1:8qnn8QA/Ewx8E3ZSsmscqsIjhhpxuy9vqdgbX2ceceM=
835831
github.com/mholt/archiver/v3 v3.5.0 h1:nE8gZIrw66cu4osS/U7UW7YDuGMHssxKutU8IfWxwWE=
836832
github.com/mholt/archiver/v3 v3.5.0/go.mod h1:qqTTPUK/HZPFgFQ/TJ3BzvTpF/dPtFVJXdQbCmeMxwc=
833+
github.com/microcosm-cc/bluemonday v1.0.6 h1:ZOvqHKtnx0fUpnbQm3m3zKFWE+DRC+XB1onh8JoEObE=
834+
github.com/microcosm-cc/bluemonday v1.0.6/go.mod h1:HOT/6NaBlR0f9XlxD3zolN6Z3N8Lp4pvhp+jLS5ihnI=
837835
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
838836
github.com/miekg/dns v1.1.30/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
839837
github.com/miekg/dns v1.1.40 h1:pyyPFfGMnciYUk/mXpKkVmeMQjfXqt3FAJ2hy7tPiLA=
@@ -1321,8 +1319,9 @@ golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwY
13211319
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
13221320
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
13231321
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
1324-
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
1325-
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
1322+
golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
1323+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
1324+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
13261325
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
13271326
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
13281327
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1418,8 +1417,8 @@ golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7w
14181417
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14191418
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14201419
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1421-
golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46 h1:V066+OYJ66oTjnhm4Yrn7SXIwSCiDQJxpBxmvqb1N1c=
1422-
golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1420+
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 h1:Bli41pIlzTzf3KEY06n+xnzK/BESIg2ze4Pgfh/aI8c=
1421+
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14231422
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
14241423
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
14251424
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

integrations/api_helper_for_declarative_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414
"time"
1515

1616
"code.gitea.io/gitea/models"
17-
auth "code.gitea.io/gitea/modules/forms"
1817
"code.gitea.io/gitea/modules/queue"
1918
api "code.gitea.io/gitea/modules/structs"
19+
"code.gitea.io/gitea/services/forms"
2020

2121
jsoniter "github.com/json-iterator/go"
2222
"github.com/stretchr/testify/assert"
@@ -243,7 +243,7 @@ func doAPIMergePullRequest(ctx APITestContext, owner, repo string, index int64)
243243
return func(t *testing.T) {
244244
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/merge?token=%s",
245245
owner, repo, index, ctx.Token)
246-
req := NewRequestWithJSON(t, http.MethodPost, urlStr, &auth.MergePullRequestForm{
246+
req := NewRequestWithJSON(t, http.MethodPost, urlStr, &forms.MergePullRequestForm{
247247
MergeMessageField: "doAPIMergePullRequest Merge",
248248
Do: string(models.MergeStyleMerge),
249249
})
@@ -255,7 +255,7 @@ func doAPIMergePullRequest(ctx APITestContext, owner, repo string, index int64)
255255
DecodeJSON(t, resp, &err)
256256
assert.EqualValues(t, "Please try again later", err.Message)
257257
queue.GetManager().FlushAll(context.Background(), 5*time.Second)
258-
req = NewRequestWithJSON(t, http.MethodPost, urlStr, &auth.MergePullRequestForm{
258+
req = NewRequestWithJSON(t, http.MethodPost, urlStr, &forms.MergePullRequestForm{
259259
MergeMessageField: "doAPIMergePullRequest Merge",
260260
Do: string(models.MergeStyleMerge),
261261
})
@@ -278,7 +278,7 @@ func doAPIManuallyMergePullRequest(ctx APITestContext, owner, repo, commitID str
278278
return func(t *testing.T) {
279279
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/merge?token=%s",
280280
owner, repo, index, ctx.Token)
281-
req := NewRequestWithJSON(t, http.MethodPost, urlStr, &auth.MergePullRequestForm{
281+
req := NewRequestWithJSON(t, http.MethodPost, urlStr, &forms.MergePullRequestForm{
282282
Do: string(models.MergeStyleManuallyMerged),
283283
MergeCommitID: commitID,
284284
})

integrations/api_pull_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"testing"
1111

1212
"code.gitea.io/gitea/models"
13-
auth "code.gitea.io/gitea/modules/forms"
1413
"code.gitea.io/gitea/modules/setting"
1514
api "code.gitea.io/gitea/modules/structs"
15+
"code.gitea.io/gitea/services/forms"
1616
issue_service "code.gitea.io/gitea/services/issue"
1717

1818
"github.com/stretchr/testify/assert"
@@ -50,7 +50,7 @@ func TestAPIMergePullWIP(t *testing.T) {
5050

5151
session := loginUser(t, owner.Name)
5252
token := getTokenForLoggedInUser(t, session)
53-
req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/merge?token=%s", owner.Name, repo.Name, pr.Index, token), &auth.MergePullRequestForm{
53+
req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/merge?token=%s", owner.Name, repo.Name, pr.Index, token), &forms.MergePullRequestForm{
5454
MergeMessageField: pr.Issue.Title,
5555
Do: string(models.MergeStyleMerge),
5656
})

integrations/attachment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestGetAttachment(t *testing.T) {
122122
t.Run(tc.name, func(t *testing.T) {
123123
//Write empty file to be available for response
124124
if tc.createFile {
125-
_, err := storage.Attachments.Save(models.AttachmentRelativePath(tc.uuid), strings.NewReader("hello world"))
125+
_, err := storage.Attachments.Save(models.AttachmentRelativePath(tc.uuid), strings.NewReader("hello world"), -1)
126126
assert.NoError(t, err)
127127
}
128128
//Actual test

integrations/git_test.go

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,13 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s
208208

209209
// Request raw paths
210210
req := NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", little))
211-
resp := session.MakeRequest(t, req, http.StatusOK)
212-
assert.Equal(t, littleSize, resp.Body.Len())
211+
resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
212+
assert.Equal(t, littleSize, resp.Length)
213213

214214
setting.CheckLFSVersion()
215215
if setting.LFS.StartServer {
216216
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", littleLFS))
217-
resp = session.MakeRequest(t, req, http.StatusOK)
217+
resp := session.MakeRequest(t, req, http.StatusOK)
218218
assert.NotEqual(t, littleSize, resp.Body.Len())
219219
assert.LessOrEqual(t, resp.Body.Len(), 1024)
220220
if resp.Body.Len() != littleSize && resp.Body.Len() <= 1024 {
@@ -224,12 +224,12 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s
224224

225225
if !testing.Short() {
226226
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", big))
227-
resp = session.MakeRequest(t, req, http.StatusOK)
228-
assert.Equal(t, bigSize, resp.Body.Len())
227+
resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
228+
assert.Equal(t, bigSize, resp.Length)
229229

230230
if setting.LFS.StartServer {
231231
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", bigLFS))
232-
resp = session.MakeRequest(t, req, http.StatusOK)
232+
resp := session.MakeRequest(t, req, http.StatusOK)
233233
assert.NotEqual(t, bigSize, resp.Body.Len())
234234
if resp.Body.Len() != bigSize && resp.Body.Len() <= 1024 {
235235
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
@@ -450,27 +450,27 @@ func doMergeFork(ctx, baseCtx APITestContext, baseBranch, headBranch string) fun
450450
t.Run("EnsureCanSeePull", doEnsureCanSeePull(baseCtx, pr))
451451

452452
// Then get the diff string
453-
var diffStr string
453+
var diffHash string
454454
t.Run("GetDiff", func(t *testing.T) {
455455
req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s/pulls/%d.diff", url.PathEscape(baseCtx.Username), url.PathEscape(baseCtx.Reponame), pr.Index))
456-
resp := ctx.Session.MakeRequest(t, req, http.StatusOK)
457-
diffStr = resp.Body.String()
456+
resp := ctx.Session.MakeRequestNilResponseHashSumRecorder(t, req, http.StatusOK)
457+
diffHash = string(resp.Hash.Sum(nil))
458458
})
459459

460460
// Now: Merge the PR & make sure that doesn't break the PR page or change its diff
461461
t.Run("MergePR", doAPIMergePullRequest(baseCtx, baseCtx.Username, baseCtx.Reponame, pr.Index))
462462
t.Run("EnsureCanSeePull", doEnsureCanSeePull(baseCtx, pr))
463-
t.Run("EnsureDiffNoChange", doEnsureDiffNoChange(baseCtx, pr, diffStr))
463+
t.Run("EnsureDiffNoChange", doEnsureDiffNoChange(baseCtx, pr, diffHash))
464464

465465
// Then: Delete the head branch & make sure that doesn't break the PR page or change its diff
466466
t.Run("DeleteHeadBranch", doBranchDelete(baseCtx, baseCtx.Username, baseCtx.Reponame, headBranch))
467467
t.Run("EnsureCanSeePull", doEnsureCanSeePull(baseCtx, pr))
468-
t.Run("EnsureDiffNoChange", doEnsureDiffNoChange(baseCtx, pr, diffStr))
468+
t.Run("EnsureDiffNoChange", doEnsureDiffNoChange(baseCtx, pr, diffHash))
469469

470470
// Delete the head repository & make sure that doesn't break the PR page or change its diff
471471
t.Run("DeleteHeadRepository", doAPIDeleteRepository(ctx))
472472
t.Run("EnsureCanSeePull", doEnsureCanSeePull(baseCtx, pr))
473-
t.Run("EnsureDiffNoChange", doEnsureDiffNoChange(baseCtx, pr, diffStr))
473+
t.Run("EnsureDiffNoChange", doEnsureDiffNoChange(baseCtx, pr, diffHash))
474474
}
475475
}
476476

@@ -514,22 +514,14 @@ func doEnsureCanSeePull(ctx APITestContext, pr api.PullRequest) func(t *testing.
514514
}
515515
}
516516

517-
func doEnsureDiffNoChange(ctx APITestContext, pr api.PullRequest, diffStr string) func(t *testing.T) {
517+
func doEnsureDiffNoChange(ctx APITestContext, pr api.PullRequest, diffHash string) func(t *testing.T) {
518518
return func(t *testing.T) {
519519
req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s/pulls/%d.diff", url.PathEscape(ctx.Username), url.PathEscape(ctx.Reponame), pr.Index))
520-
resp := ctx.Session.MakeRequest(t, req, http.StatusOK)
521-
expectedMaxLen := len(diffStr)
522-
if expectedMaxLen > 800 {
523-
expectedMaxLen = 800
524-
}
525-
actual := resp.Body.String()
526-
actualMaxLen := len(actual)
527-
if actualMaxLen > 800 {
528-
actualMaxLen = 800
529-
}
520+
resp := ctx.Session.MakeRequestNilResponseHashSumRecorder(t, req, http.StatusOK)
521+
actual := string(resp.Hash.Sum(nil))
530522

531-
equal := diffStr == actual
532-
assert.True(t, equal, "Unexpected change in the diff string: expected: %s but was actually: %s", diffStr[:expectedMaxLen], actual[:actualMaxLen])
523+
equal := diffHash == actual
524+
assert.True(t, equal, "Unexpected change in the diff string: expected hash: %s but was actually: %s", diffHash, actual)
533525
}
534526
}
535527

0 commit comments

Comments
 (0)