Skip to content

Commit b908742

Browse files
committed
Merge branch 'master' into assets_dir
2 parents 01c3af0 + 99f835b commit b908742

File tree

121 files changed

+2252
-884
lines changed

Some content is hidden

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

121 files changed

+2252
-884
lines changed

.drone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ steps:
501501
pull: always
502502
image: techknowlogick/xgo:go-1.16.x
503503
commands:
504-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt -y install nodejs bsdtar\|libarchive-tools
504+
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
505505
- export PATH=$PATH:$GOPATH/bin
506506
- make release
507507
environment:
@@ -597,7 +597,7 @@ steps:
597597
pull: always
598598
image: techknowlogick/xgo:go-1.16.x
599599
commands:
600-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs bsdtar\|libarchive-tools
600+
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
601601
- export PATH=$PATH:$GOPATH/bin
602602
- make release
603603
environment:

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ coverage.all
8181
/public/fonts
8282
/public/img/webpack
8383
/web_src/fomantic/node_modules
84-
/web_src/fomantic/semantic.json
8584
/web_src/fomantic/build/*
8685
!/web_src/fomantic/build/semantic.js
8786
!/web_src/fomantic/build/semantic.css
@@ -95,7 +94,6 @@ coverage.all
9594
!/web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2
9695
/VERSION
9796
/.air
98-
/.npm-cache
9997

10098
# Snapcraft
10199
snap/.snapcraft/

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
audit=false
22
fund=false
3+
update-notifier=false
34
package-lock=true
45
save-exact=true
5-
cache=.npm-cache

Makefile

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ 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-
1917
DIST := dist
2018
DIST_DIRS := $(DIST)/binaries $(DIST)/release
2119
IMPORT := code.gitea.io/gitea
@@ -93,8 +91,6 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
9391

9492
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/models/migrations code.gitea.io/gitea/integrations/migration-test code.gitea.io/gitea/integrations,$(shell $(GO) list -mod=vendor ./... | grep -v /vendor/))
9593

96-
FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
97-
FOMANTIC_DEST := web_src/fomantic/build/semantic.js web_src/fomantic/build/semantic.css
9894
FOMANTIC_WORK_DIR := web_src/fomantic
9995

10096
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
@@ -115,6 +111,8 @@ TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
115111

116112
TEST_TAGS ?= sqlite sqlite_unlock_notify
117113

114+
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR)
115+
118116
GO_DIRS := cmd integrations models modules routers build services vendor tools
119117

120118
GO_SOURCES := $(wildcard *.go)
@@ -589,7 +587,7 @@ install: $(wildcard *.go)
589587
build: frontend backend
590588

591589
.PHONY: frontend
592-
frontend: node-check $(WEBPACK_DEST)
590+
frontend: $(WEBPACK_DEST)
593591

594592
.PHONY: backend
595593
backend: go-check generate $(EXECUTABLE)
@@ -654,16 +652,16 @@ release-compress: | $(DIST_DIRS)
654652
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
655653

656654
.PHONY: release-sources
657-
release-sources: | $(DIST_DIRS) npm-cache
655+
release-sources: | $(DIST_DIRS)
658656
echo $(VERSION) > $(STORED_VERSION_FILE)
659-
$(eval EXCL := --exclude=$(shell [ ! "$(TAR)" = "tar" ] && echo "^" )./)
660-
$(eval EXCL_RECURSIVE := --exclude=)
661-
$(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 .
657+
# bsdtar needs a ^ to prevent matching subdirectories
658+
$(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
659+
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
662660
rm -f $(STORED_VERSION_FILE)
663661

664662
.PHONY: release-docs
665663
release-docs: | $(DIST_DIRS) docs
666-
$(TAR) -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
664+
tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
667665

668666
.PHONY: docs
669667
docs:
@@ -676,25 +674,6 @@ node_modules: package-lock.json
676674
npm install --no-save
677675
@touch node_modules
678676

679-
.PHONY: npm-cache
680-
npm-cache: .npm-cache $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui
681-
682-
.npm-cache: package-lock.json
683-
rm -rf .npm-cache
684-
$(eval ESBUILD_VERSION := $(shell node -p "require('./package-lock.json').dependencies.esbuild.version"))
685-
npm config --userconfig=.npmrc set cache=.npm-cache
686-
rm -rf node_modules && npm install --no-save
687-
npm config --userconfig=$(FOMANTIC_WORK_DIR)/.npmrc set cache=../../.npm-cache
688-
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
689-
rm -rf $(FOMANTIC_WORK_DIR)/node_modules
690-
@touch .npm-cache
691-
692-
.PHONY: npm-uncache
693-
npm-uncache:
694-
rm -rf .npm-cache
695-
npm config --userconfig=$(FOMANTIC_WORK_DIR)/.npmrc rm cache
696-
npm config --userconfig=.npmrc rm cache
697-
698677
.PHONY: npm-update
699678
npm-update: node-check | node_modules
700679
npx updates -cu
@@ -703,30 +682,18 @@ npm-update: node-check | node_modules
703682
@touch node_modules
704683

705684
.PHONY: fomantic
706-
fomantic: $(FOMANTIC_DEST)
707-
708-
$(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui:
709-
ln -sf ../../semantic.json $(FOMANTIC_WORK_DIR)
710-
cd $(FOMANTIC_WORK_DIR); \
711-
rm -rf node_modules && mkdir node_modules && \
712-
npm install fomantic-ui; \
713-
rm -f semantic.json
714-
@touch $(FOMANTIC_WORK_DIR)/node_modules
715-
716-
$(FOMANTIC_DEST): $(FOMANTIC_CONFIGS) $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui
717-
ln -sf ../../semantic.json $(FOMANTIC_WORK_DIR)
685+
fomantic:
718686
rm -rf $(FOMANTIC_WORK_DIR)/build
719-
cd $(FOMANTIC_WORK_DIR); \
720-
cp -f theme.config.less node_modules/fomantic-ui/src/theme.config; \
721-
cp -rf _site node_modules/fomantic-ui/src/; \
722-
npx gulp -f node_modules/fomantic-ui/gulpfile.js build; \
723-
rm -f semantic.json
724-
@touch $(FOMANTIC_DEST)
687+
cd $(FOMANTIC_WORK_DIR) && npm install --no-save
688+
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
689+
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
690+
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
725691

726692
.PHONY: webpack
727693
webpack: $(WEBPACK_DEST)
728694

729-
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_modules
695+
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json
696+
@$(MAKE) -s node-check node_modules
730697
rm -rf $(WEBPACK_DEST_ENTRIES)
731698
npx webpack
732699
@touch $(WEBPACK_DEST)

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,11 @@ or if sqlite support is required:
7777
The `build` target is split into two sub-targets:
7878

7979
- `make backend` which requires [Go 1.13](https://golang.org/dl/) or greater.
80-
- `make frontend` which requires [Node.js 12.17](https://nodejs.org/en/download/) or greater.
80+
- `make frontend` which requires [Node.js 12.17](https://nodejs.org/en/download/) or greater and Internet connectivity to download npm dependencies.
8181

82-
If pre-built frontend files are present it is possible to only build the backend:
82+
When building from the official source tarballs which include pre-built frontend files, the `frontend` target will not be triggered, making it possible to build without Node.js and Internet connectivity.
8383

84-
TAGS="bindata" make backend
85-
86-
Parallelism is not supported for these targets, so please don't include `-j <num>`.
84+
Parallelism (`make -j <num>`) is not supported.
8785

8886
More info: https://docs.gitea.io/en-us/install-from-source/
8987

cmd/admin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ func runDeleteUser(c *cli.Context) error {
512512
return models.DeleteUser(user)
513513
}
514514

515-
func runRepoSyncReleases(c *cli.Context) error {
515+
func runRepoSyncReleases(_ *cli.Context) error {
516516
if err := initDB(); err != nil {
517517
return err
518518
}
@@ -578,14 +578,14 @@ func getReleaseCount(id int64) (int64, error) {
578578
)
579579
}
580580

581-
func runRegenerateHooks(c *cli.Context) error {
581+
func runRegenerateHooks(_ *cli.Context) error {
582582
if err := initDB(); err != nil {
583583
return err
584584
}
585585
return repo_module.SyncRepositoryHooks(graceful.GetManager().ShutdownContext())
586586
}
587587

588-
func runRegenerateKeys(c *cli.Context) error {
588+
func runRegenerateKeys(_ *cli.Context) error {
589589
if err := initDB(); err != nil {
590590
return err
591591
}

cmd/hook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Gitea or set your environment appropriately.`, "")
166166
}
167167

168168
// the environment setted on serv command
169-
isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")
169+
isWiki := os.Getenv(models.EnvRepoIsWiki) == "true"
170170
username := os.Getenv(models.EnvRepoUsername)
171171
reponame := os.Getenv(models.EnvRepoName)
172172
userID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64)
@@ -322,7 +322,7 @@ Gitea or set your environment appropriately.`, "")
322322

323323
// the environment setted on serv command
324324
repoUser := os.Getenv(models.EnvRepoUsername)
325-
isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")
325+
isWiki := os.Getenv(models.EnvRepoIsWiki) == "true"
326326
repoName := os.Getenv(models.EnvRepoName)
327327
pusherID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64)
328328
pusherName := os.Getenv(models.EnvPusherName)

cmd/serv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import (
1717
"time"
1818

1919
"code.gitea.io/gitea/models"
20-
"code.gitea.io/gitea/modules/lfs"
2120
"code.gitea.io/gitea/modules/log"
2221
"code.gitea.io/gitea/modules/pprof"
2322
"code.gitea.io/gitea/modules/private"
2423
"code.gitea.io/gitea/modules/setting"
24+
"code.gitea.io/gitea/services/lfs"
2525

2626
"github.com/dgrijalva/jwt-go"
2727
jsoniter "github.com/json-iterator/go"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
"path"
10+
"testing"
11+
12+
"code.gitea.io/gitea/models"
13+
"code.gitea.io/gitea/modules/lfs"
14+
"code.gitea.io/gitea/modules/setting"
15+
api "code.gitea.io/gitea/modules/structs"
16+
17+
"github.com/stretchr/testify/assert"
18+
)
19+
20+
func TestAPIRepoLFSMigrateLocal(t *testing.T) {
21+
defer prepareTestEnv(t)()
22+
23+
oldImportLocalPaths := setting.ImportLocalPaths
24+
oldAllowLocalNetworks := setting.Migrations.AllowLocalNetworks
25+
setting.ImportLocalPaths = true
26+
setting.Migrations.AllowLocalNetworks = true
27+
28+
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
29+
session := loginUser(t, user.Name)
30+
token := getTokenForLoggedInUser(t, session)
31+
32+
req := NewRequestWithJSON(t, "POST", "/api/v1/repos/migrate?token="+token, &api.MigrateRepoOptions{
33+
CloneAddr: path.Join(setting.RepoRootPath, "migration/lfs-test.git"),
34+
RepoOwnerID: user.ID,
35+
RepoName: "lfs-test-local",
36+
LFS: true,
37+
})
38+
resp := MakeRequest(t, req, NoExpectedStatus)
39+
assert.EqualValues(t, http.StatusCreated, resp.Code)
40+
41+
store := lfs.NewContentStore()
42+
ok, _ := store.Verify(lfs.Pointer{Oid: "fb8f7d8435968c4f82a726a92395be4d16f2f63116caf36c8ad35c60831ab041", Size: 6})
43+
assert.True(t, ok)
44+
ok, _ = store.Verify(lfs.Pointer{Oid: "d6f175817f886ec6fbbc1515326465fa96c3bfd54a4ea06cfd6dbbd8340e0152", Size: 6})
45+
assert.True(t, ok)
46+
47+
setting.ImportLocalPaths = oldImportLocalPaths
48+
setting.Migrations.AllowLocalNetworks = oldAllowLocalNetworks
49+
}

integrations/git_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
"code.gitea.io/gitea/models"
2020
"code.gitea.io/gitea/modules/git"
21+
"code.gitea.io/gitea/modules/lfs"
2122
"code.gitea.io/gitea/modules/setting"
2223
api "code.gitea.io/gitea/modules/structs"
2324
"code.gitea.io/gitea/modules/util"
@@ -218,7 +219,7 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s
218219
assert.NotEqual(t, littleSize, resp.Body.Len())
219220
assert.LessOrEqual(t, resp.Body.Len(), 1024)
220221
if resp.Body.Len() != littleSize && resp.Body.Len() <= 1024 {
221-
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
222+
assert.Contains(t, resp.Body.String(), lfs.MetaFileIdentifier)
222223
}
223224
}
224225

@@ -232,7 +233,7 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s
232233
resp := session.MakeRequest(t, req, http.StatusOK)
233234
assert.NotEqual(t, bigSize, resp.Body.Len())
234235
if resp.Body.Len() != bigSize && resp.Body.Len() <= 1024 {
235-
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
236+
assert.Contains(t, resp.Body.String(), lfs.MetaFileIdentifier)
236237
}
237238
}
238239
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/master
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[core]
2+
bare = false
3+
repositoryformatversion = 0
4+
filemode = false
5+
symlinks = false
6+
ignorecase = true
7+
logallrefupdates = true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Unnamed repository; edit this file 'description' to name the repository.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout.\n"; exit 2; }
3+
git lfs post-checkout "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-commit.\n"; exit 2; }
3+
git lfs post-commit "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-merge.\n"; exit 2; }
3+
git lfs post-merge "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.\n"; exit 2; }
3+
git lfs pre-push "$@"
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dummy2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dummy1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
546244003622c64b2fc3c2cd544d7a29882c8383

0 commit comments

Comments
 (0)